darking050
darking050

Reputation: 637

Can't get a metadata error in WCF endpoint

I am doing a test in VS 2012 for WCF. which has a custom Http binding, and it is used in a endpoint. But it gives an error that it can't find the metadata when testing it in the wcfclient.exe

The following is the custom code that I made in web.config file.

<bindings>
      <basicHttpBinding>
        <binding name="MaxHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000"
                 maxBufferSize="20000000" 
                 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
               maxArrayLength="200000000"
               maxStringContentLength="200000000"/>

        </binding>
      </basicHttpBinding>
      <!---->
    </bindings>
    <services>
      <service name="AdventureW.Service.Database.AwService">
        <endpoint address="http://localhost:49551" binding="basicHttpBinding" bindingConfiguration="MaxHttp" contract="AdventureW.Service.Database.IWsService"/>
      </service>
    </services>

Upvotes: 0

Views: 928

Answers (1)

Trey Combs
Trey Combs

Reputation: 710

Add a MEX (Metadata Exchange) endpoint to your service, add a behavior that allows for Http gets, and update your service to use that behavior:

  <system.serviceModel>
    <bindings> 
      ... 
    </bindings> 

    <services>    
      <service name="AdventureW.Service.Database.AwService" behaviorConfiguration="ServiceBehavior">    
        <endpoint address="http://localhost:49551" binding="basicHttpBinding" bindingConfiguration="MaxHttp" contract="AdventureW.Service.Database.IWsService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>    
    </services>  

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Upvotes: 1

Related Questions