How can a WCF client consume a multipart/related java webservice reponse?
c#, content-type, java, response, wcf
Solution
Max' and Mehmet's hints showed the right direction but I had to change a bit more. Since I used the element in , the wcf configuration ignored the messageEncoding="Mtom" attribute.
Instead of using attribute, it seems better to use the element directly:
<binding name="energylinkSOAP">
<mtomMessageEncoding messageVersion="Soap12" />
<httpsTransport requireClientCertificate="true" />
</binding>
By that you also can define more configurations, such as messageVersion.
Problem
I wrote a WCF C# client that consumes a Java webservice: ``` var client = new abcClient("abc"); var response = client.AbcTransaction(msg); ``` The WCF binding info from web.config is: ``` <customBinding> <binding name="abcSOAP"> <textMessageEncoding messageVersion="Soap12" /> <httpsTransport requireClientCertificate="true" /> </binding> </customBinding> ``` It looks pretty straight-forward, right? ...And indeed, SoapFaults are easy to consume: ``` HTTP/1.1 500 Internal Server Error Content-Length: 783 Content-Type: application/soap+xml;charset=UTF-8 Server: Microsoft-IIS/8.0 Date: Mon, 18 Nov 2013 14:06:18 GMT <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body><soap:Fault>... ``` However, the webservice sends "regular" responses in the multipart/related content-type: ``` HTTP/1.1 200 OK Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:c79210c3-bbef-4aa3-82ae-6a20c7a96564"; start="<root.message@cxf.apache.org>"; start-info="application/soap+xml" Content-Encoding: gzip Vary: Accept-Encoding Server: Microsoft-IIS/8.0 Date: Mon, 18 Nov 2013 14:11:25 GMT Content-Length: 658 --uuid:c79210c3-bbef-4aa3-82ae-6a20c7a96564 Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; Content-Transfer-Encoding: binary Content-ID: <root.message@cxf.apache.org> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">... ``` This leads to a ProtocolException in the WCF client because the WCF client does not expect a multipart/related answer. The ProtocolException message is (in German): Der Inhaltstyp "multipart/related; type="application/xop+xml"; boundary="uuid:ead716a3-4b8b-4207-ad66-b9f18ae368b2"; start=""; start-info="application/soap+xml"" der Antwortnachricht stimmt nicht mit dem Inhaltstyp der Bindung (application/soap+xml; charset=utf-8) überein. Wenn Sie einen benutzerdefinierten Encoder verwenden, sollten Sie sicherstellen, dass die IsContentTypeSupported-Methode korrekt implementiert ist. Die ersten 1024 Bytes der Antwort waren: ... In English: The content type "multipart/related; type="application/xop+xml"; boundary="uuid:ead716a3-4b8b-4207-ad66-b9f18ae368b2"; start=""; start-info="application/soap+xml"" of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ... Does anyone have an idea how I can consume this multipart/related message with a WCF client (without using the HttpWebRequest class)? Is there any configuration available for this szenario?