Alex Rivera | Logout

mexHttpBinding - Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract

Asked 2011-09-16T08:11:10.357
13

I know this has been asked many times, and answered many times, but, all the provided samples that should be working don't seem to want to work for me today.

When I try to start the host, I keep getting the following error:

"The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service TraceService. Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract."

My service is being hosted in a managed windows service host as per Microsoft's example: http://msdn.microsoft.com/en-us/library/ms733069%28v=vs.90%29.aspx

And here is my nice and simple config:

  <system.serviceModel>
    <services>
      <service name="Daff.Lae.Service.TraceService">
        <endpoint address="" binding="wsHttpBinding" name="TraceService" contract="Contracts.Service.ITraceService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/TraceService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Of course, the problem becomes more interesting when there are no errors if I remove this line:

<endpoint ad
Edit
Report

1 Answer

2

As you're using WS-Http you are binding to an HTTPS protocol, so you need to use the correct MEX binding;

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 

and change the baseaddress to a https one.

Or (the other way around) convert your wsHttp binding to a basicHttp binding and things will start working for you.

answered 2011-09-20T21:45:41.680

Your Answer