无法在WCF端点中获取元数据错误

时间:2012-07-23 22:42:02

标签: wcf wcf-data-services

我正在VS 2012中为WCF做一个测试。它具有自定义Http绑定,并在端点中使用。但是它在wcfclient.exe

中测试时发现了无法找到元数据的错误

以下是我在web.config文件中创建的自定义代码。

<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>

1 个答案:

答案 0 :(得分:1)

向您的服务添加MEX(元数据交换)端点,添加允许Http获取的行为,并更新您的服务以使用该行为:

  <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>