WCF 客户端与 Java WS 对话,异常:内容类型 application/xop+xml;类型=“应用程序/soap+xml";响应消息的 [英] WCF client talking to Java WS, exception: The content type application/xop+xml; type="application/soap+xml" of the response message

查看:31
本文介绍了WCF 客户端与 Java WS 对话,异常:内容类型 application/xop+xml;类型=“应用程序/soap+xml";响应消息的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与 Java WS 交谈时遇到问题.我使用wsHttpBinding"绑定客户端证书进行身份验证,消息编码设置为文本",.net 框架为 4.0.服务器端是 Java,我无法控制它.连接是通过 Fiddler 代理的(这就是我看到在线请求的方式,比跟踪System.Net"更加用户友好).

I'm having problems talking to Java WS. I'm using "wsHttpBinding" binding with client certificates for authentication, message encoding is set "Text", .net framework is 4.0. Server side is Java and I have no control over it. Connection is being proxied through Fiddler (this is how I see requests on the wire, much more user friendly than tracing "System.Net").

我得到的异常如下:

内容类型application/xop+xml;响应消息的 type="application/soap+xml" 与绑定的内容类型不匹配(application/soap+xml; charset=utf-8).

如果我将消息编码更改为Mtom",则异常更改:

If I change message encoding to "Mtom", then the exception changes:

内容类型application/xop+xml;响应消息的 type="application/soap+xml" 与绑定的内容类型不匹配(multipart/related; type="application/xop+xml").

服务器接受请求的文本"和Mtom"消息编码,并且响应始终相同.这是我从服务器得到的原始响应:

Server is accepting both "Text" and "Mtom" message encodings for request, and response is always the same. This is the raw response that I'm getting from the server:

HTTP/1.1 200 OK
X-Backside-Transport: OK OK
Connection: Keep-Alive
X-Powered-By: Servlet/3.0
SOAPAction: ""
Content-Type: application/xop+xml; type="application/soap+xml"
Content-Language: en-US
Date: Thu, 25 Jul 2013 13:05:09 GMT
Content-Length: 628

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope  ...   </env:Envelope>

从我阅读的所有文档中,返回的响应介于常规 SOAP 消息和 MTOM 消息之间.我这么说是因为我见过的每个例子都说 MTOM 请求和响应使用 MIME 作为通信的信封:常规 SOAP 消息封装在 XOP 包中,然后这个 XOP 消息用 MIME 封装.甚至 W3C 推荐使用 MIME 来处理 XOP 包:W3C:XML-binary Optimized Packaging.摘自此链接:

From all the docs which I have been reading, response that is being returned is somewhere between regular SOAP message and MTOM message. I'm saying this because every example which I've seen says that the MTOM request and response use MIME as an envelope for communication: regular SOAP message is enveloped in XOP package, and then this XOP message is enveloped with MIME. Even the W3C recommendation uses MIME for XOP packages: W3C: XML-binary Optimized Packaging. Excerpt from this link:

Content-Type: Multipart/Related;boundary=...

如果我尝试使用工具soapUI"(用 Java 编写,可从www.soapui.org"获得)调用 Web 服务,服务调用将成功执行并且响应被解析而没有任何问题.

If I try calling web service using tool "soapUI" (written in Java, available from "www.soapui.org"), service call is successfully executed and response is parsed without any problem.

仅供参考,这是来自 MSDN WCF 论坛.,但那里还没有回复.

FYI, this is a cross-post from MSDN WCF forum., but no responses there yet.

感谢任何想法,提前致谢,

Any idea is appreciated, thanks in advance,

亚历克斯

推荐答案

我也在使用 CXF,并且有一个 C# 客户端.尝试修改您的绑定设置,将 textMessageEncoding 替换为 mtomMessageEncoding.像这样:

I'm also using CXF, and has a C# client. Try modifying your binding setting, replace textMessageEncoding with mtomMessageEncoding. Something like this:

<binding name="yourSoapBinding">
    <mtomMessageEncoding messageVersion="Soap12"/>
    <httpTransport />
</binding>

这篇关于WCF 客户端与 Java WS 对话,异常:内容类型 application/xop+xml;类型=“应用程序/soap+xml";响应消息的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆