gpt4 book ai didi

WCF - 无法获取元数据,但在删除 XML 端点时工作?

转载 作者:行者123 更新时间:2023-12-01 12:52:06 25 4
gpt4 key购买 nike

我在使用 WCF 测试客户端时遇到问题。我无法连接到我的 WebService,因为它一直遇到此错误:

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 Endpoint 有问题?这很奇怪,因为 XML 端点共享 JSON 端点的绑定(bind)配置,而 JSON 没有任何问题。

另外,让我澄清一下,我只是在使用 WCF 测试客户端时遇到问题。 JSON 和 XML 端点都工作正常。

编辑:

我尝试评论 XML 端点,发布,然后通过 WCF 测试客户端连接。然后我取消注释 XML Endpoint,重新发布。 WCF 测试客户端仍然有效——我的意思是我可以发送和接收数据。当我刷新服务时,再次弹出无法获取元数据错误。

最佳答案

似乎 WCF 不允许对 2 个端点使用相同的配置。

有解决此问题的解决方法:

  • 更改bindingConfiguration端点属性 address="x"来自 webweb2
  • 添加新的 web2 webHttpBinding配置(复制网页配置):

  • 新绑定(bind)配置的代码:
    <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 的 WSDL 或类似协议(protocol)或 wsHttpBinding .当 WCF 测试客户端尝试在两种情况下获取元数据时(当 WCF 测试客户端失败和不失败时),服务返回错误,但由于某种原因,在建议的解决方法的情况下,WCF 测试客户端设法吞下错误。很难说为什么没有 WCF 测试客户端源代码。

    跟踪查看器中的错误:

    enter image description here

    关于WCF - 无法获取元数据,但在删除 XML 端点时工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11627392/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com