在WCF端点中无法获取元数据错误
问题描述:
我正在为WCF在VS 2012中进行测试。它具有自定义的Http绑定,并在端点中使用。但它给出了一个错误,它在wcfclient.exe
在WCF端点中无法获取元数据错误
中测试时找不到元数据以下是我在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>
答
一个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>
我照你说的,但我有这个错误。错误:无法从http:// localhost:49551/WsService.svc获取元数据如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用元数据发布。 – darking050 2012-07-24 21:08:30
您能否提供有关您如何托管此服务的详细信息? – 2012-08-06 14:12:26