gpt4 book ai didi

c# - 使用 Web 服务时出错,内容类型 "application/xop+xml"与预期类型 "text/xml"不匹配

转载 作者:行者123 更新时间:2023-12-01 23:56:08 29 4
gpt4 key购买 nike

在使用我公司购买的产品的网络服务时,我遇到了一个奇怪的问题。该产品名为 Campaign Commander,由一家名为 Email Vision 的公司制造。我们正在尝试使用“Data Mass Update SOAP API”。

每当我尝试调用 Web 服务上的任何方法时,调用实际上都会成功,但客户端在处理响应时会失败,并且会出现异常。

错误的详细信息如下,感谢您提供的帮助。

使用 Web 引用时出错(旧式 Web 服务客户端)

当使用该服务作为 Web 引用时,我进行的任何调用都会收到 InvalidOperationException ,并显示以下消息:

Client found response content type of 'multipart/related; type="application/xop+xml"; boundary="uuid:170e63fa-183c-4b18-9364-c62ca545a6e0"; start="<root.message@cxf.apache.org>"; start-info="text/xml"', but expected 'text/xml'.
The request failed with the error message:
--

--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/">
<return>DpKTe-9swUeOsxhHH9t-uLPeLyg-aa2xk3-aKe9oJ5S9Yymrnuf1FxYnzpaFojsQSkSCbJsZmrZ_d3v2-7Hj</return>
</ns2:openApiConnectionResponse>
</soap:Body>
</soap:Envelope>
--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0--
--.

正如您所看到的,响应soap信封看起来有效(这是一个有效的响应并且调用成功),但客户端的内容类型似乎有问题并生成异常。

使用服务引用时出错(WCF 客户端)

当我将服务作为服务引用使用时,我进行的任何调用都会收到 ProtocolException ,并显示以下消息:

The content type multipart/related; type="application/xop+xml"; boundary="uuid:af66440a-012e-4444-8814-895c843de5ec"; start="<root.message@cxf.apache.org>"; start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 648 bytes of the response were: '
--uuid:af66440a-012e-4444-8814-895c843de5ec
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/">
<return>Dqaqb-MJ9V_eplZ8fPh4tdHUbxM-ZtuZsDG6GalAGZSfSzyxgtuuIxZc3aSsnhI4b0SCbJsZmrZ_d3v2-7G8</return>
</ns2:openApiConnectionResponse>
</soap:Body>
</soap:Envelope>
--uuid:af66440a-012e-4444-8814-895c843de5ec--'.

就像前面的例子一样;我们得到了有效的肥皂响应并且调用成功,但客户端似乎有内容类型问题并生成了异常。

是否可以设置任何选项,以便客户端不会遇到响应类型问题?我已经进行了一些 Google 搜索,但到目前为止我发现的任何内容都对我没有帮助。

最佳答案

对于遇到同样问题的人;我找到了一种将 Web 服务用作服务引用 (WCF) 的解决方案。 BasicHttpBinding.MessageEncoding属性需要设置为“Mtom”。

这是所需配置设置的片段:

<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom">
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>

编辑:如果您在自定义绑定(bind)方面遇到同样的问题,请参阅 answer from @robmzd .

我还没有找到将其用作旧式 Web 引用的解决方案。

关于c# - 使用 Web 服务时出错,内容类型 "application/xop+xml"与预期类型 "text/xml"不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10496186/

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