The contract name 'IMetadataExchange' could not be found in
the list of contracts implemented by the service HelloWorld. Add a ServiceMetadataBehavior to the
configuration file or to the ServiceHost directly to enable support for this
contract.
This error occurs when we define a servicebehavior and did not attach the behavior to the service name configuration.
If your configuration looks like below and when you try to run the host, you will get the error specified above.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HelloWorldService.HelloWorld">
<endpoint contract="HelloWorldService.IHelloWorld" address="HelloWorld" binding="basicHttpBinding"></endpoint>
<endpoint contract="IMetadataExchange" address="Mex" binding="mexHttpBinding"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The solution is as below in this case (Add the behaviorConfiguration in the service section):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HelloWorldService.HelloWorld" behaviorConfiguration="MyServiceBehavior">
<endpoint contract="HelloWorldService.IHelloWorld" address="HelloWorld" binding="basicHttpBinding"></endpoint>
<endpoint contract="IMetadataExchange" address="Mex" binding="mexHttpBinding"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
8 comments:
A very good article.. it solved my problem
thank u so much ... u r the one ;-)
good answer
Thank you !!
Also solved my problem. Thank you.
Good to know and thanks for visiting...
Much thanks man for helping on this niggle.
Thank you...
Post a Comment