WCF client talking to Java WS, exception: The content type application/xop+xml; type=“application/soap+xml” of the response message

心已入冬 提交于 2019-12-23 09:33:45

问题


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").

Exception I get is following:

The content type application/xop+xml; type="application/soap+xml" of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).

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

The content type application/xop+xml; type="application/soap+xml" of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml").

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>

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=...

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.

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

Any idea is appreciated, thanks in advance,

Alex


回答1:


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>



回答2:


Try setting the message encoding in the binding configuration to messageEncoding="Mtom" and basicHTTPBinding instead of wsHTTP one...

Hope it helps!



来源:https://stackoverflow.com/questions/17879658/wcf-client-talking-to-java-ws-exception-the-content-type-application-xopxml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!