.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”

在为我公司购买的产品消费webservice时,我有一个奇怪的问题。该产品称为“运动指挥官”,由“Vision Vision”公司制造。我们正在尝试使用“数据批量更新SOAP API”。

每当我尝试调用webservice上的任何方法时,调用实际上会成功,但是当处理响应时客户端失败,并且我收到异常。

错误的细节如下,谢谢你们可以提供的任何帮助。

使用Web引用错误(旧式webservice客户端)

当作为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--
--.

如你所见,响应肥皂包看起来是有效的(这是一个有效的响应,并且调用成功),但客户端似乎对内容类型有问题并产生异常。

使用服务引用错误(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--'.

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

有没有我可以设置的选项,所以客户端没有响应类型的问题?我已经做了一些谷歌的搜索,但我发现没有什么帮助我到目前为止。

解决方法

对于同样问题的人来说,我已经找到一个消费Web服务作为服务引用(WCF)的解决方案。 BasicHttpBinding.MessageEncoding属性需要设置为“Mtom”。

以下是所需配置设置的代码段:

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

编辑:如果您有与自定义绑定相同的问题,请参阅answer from @robmzd

我仍然没有找到一个解决方案来消费它作为一个旧式的Web引用。

相关文章

1.使用ajax调用varxhr;functioninvoke(){if(window.ActiveXO...
               好不容易把WebService服务器...
1新建一个工程项目用来做服务端增加一个MyService1类文件pac...
packagecom.transsion.util;importjava.io.BufferedReader;i...
再生产wsdl文件时重写描述文件1usingSystem;2usingSystem.Co...
一般情况下,使用eclipse自带的jax-ws生成webservice会自动生...