WCF - 无法获取元数据,但在移除XML端点时起作用?
我遇到了WCF测试客户端的问题。我无法连接到我的web服务,因为它使达不到这个错误:WCF - 无法获取元数据,但在移除XML端点时起作用?
Error: Cannot obtain Metadata from http://xxx.xxxxxxxx.xxx/DPITerminal.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://xxx.xxxxxxxx.xxx/DPITerminal.svc
Metadata contains a reference that cannot be resolved: 'http://xxx.xxxxxxxx.xxx/DPITerminal.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://xxx.xxxxxxxx.xxx/DPITerminal.svc . The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..HTTP GET Error URI: http://xxx.xxxxxxxx.xxx/DPITerminal.svc There was an error downloading 'http://xxx.xxxxxxxx.xxx/DPITerminal.svc'.
这里是我的web.config:Link。
正如你所看到的,我已经有
<serviceMetadata httpGetEnabled="true" />
以及
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mex" contract="IMetadataExchange" />
如其他StackOverflow的问题建议。仍然不起作用。
我还注意到,当我评论以下端点:
<endpoint address="x" behaviorConfiguration="poxBehavior" binding="webHttpBinding" bindingConfiguration="web" contract="xxx.xxxxxxxx.xxxxxx.WebService.IDPITerminal" />
一切正常。所以我想我的XML端点有问题?这很奇怪,因为XML端点共享JSON端点的绑定配置,而JSON端点没有任何问题。
此外,让我澄清,我只有WCF测试客户端的问题。 XML Endpoint的JSON &工作正常。
编辑:
我想评论的XML端点,发布,然后通过WCF测试客户端连接。然后我取消注释了XML Endpoint,重新发布。 WCF测试客户端仍然有效 - 我的意思是我可以发送和接收数据。当我刷新服务时,无法获取元数据错误再次弹出。
看来WCF不允许为2个端点使用相同的配置。
有变通方法来解决该问题:
- 变化
bindingConfiguration
端点address="x"
从web
属性web2
- 添加新的web2的
webHttpBinding
配置(复制网络配置):
代码新的绑定配置:
<webHttpBinding>
<binding name="web" ... />
<binding name="web2" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" allowCookies="true" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="8192" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
更新:
WCF测试客户端是无法获得的元数据webHttpBinding
,因为这样的元数据不存在。 RESTfull服务不支持用于basicHttpBinding
或wsHttpBinding
的WSDL或类似协议。当WCF测试客户端试图在两种情况下都获取元数据时(WCF测试客户端出现故障时,WCF测试客户端出现故障时),但由于某种原因,WCF测试客户端设法解决了错误时,服务返回错误。很难说为什么没有WCF测试客户端源代码。
错误跟踪查看:
我尝试过了,它的工作。 WCF的行为仍然非常奇怪。 – 2012-07-28 22:30:48