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

2

6

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

Odeliaodelinda answered 26/7, 2013 at 11:0 Comment(3)
I am facing the exact same issue. Creating a custom binding and setting the messageVersion="Soap12" didn't work for me. One difference I can see is my web service call is https but this post is for http it seems.Kado
Did you find a solution? I'm having the same problem. But the binding configuration suggested in the first answer it's not valid for web.config.Wuhan
HTTP vs HTTPS makes no difference: this is just transport detail. The issue is formatting of the message. The problem I had was that government entity was using some Java server (using IBM WebSphere stack) and their stack was producing non-conforming messages. There were two options in my case: 1.) use SoapUI as external app which will download the message and then parse the XML in C# 2.) edit raw XML which comes through the network and change message XML to conform to standards -> this way everything was done in C#.Odeliaodelinda
C
3

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>
Condolent answered 4/8, 2015 at 5:15 Comment(0)
S
0

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

Hope it helps!

Stenopetalous answered 8/9, 2013 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.