Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I mix message encoding types (Text/MTOM) in the Request & Response of a Web Service client application using WCF (or WSE 3)?
    primarykey
    data
    text
    <p>Here is my problem. I am hitting a web service (hosted on a Java based server) that will only accept text encoded Requests, but it returns MTOM Responses. What I've found is that if I set the web service to RequireMtom, it sends an Mtom request! Unfortunately, the server chokes on an Mtom request and returns a 500 error. However, if I set it to Text message encoding, the response comes back correctly with a multipart MIME (MTOM) response that errors out the Microsoft Web Service API (sample error below). It's expecting a text encoded response because the request was text encoded. I would like to RequireMtom on the response only. Can anyone help me here?</p> <p><em>As you can see in the error below (which occurs with the standard web services API, WCF or WSE3), when I send the request with text encoding, the response comes back correctly with all the data in a multipart/related response, but the .net framework chokes!</em></p> <p><strong>ERROR MESSAGE WITH WSE:</strong></p> <pre><code>Client found response content type of 'multipart/related; type="text/xml"; start="&lt;1AE0B46A85B0186B5D136D12E1EE286E&gt;"; boundary="----=_Part_209564_1891070135.1226526701833"', but expected 'text/xml'. The request failed with the error message: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at TestWseService.AdesaJasperWse.ManagementServiceService.runReport(String requestXmlString) in C:\Documents and Settings\xxx\My Documents\Visual Studio 2005\Projects\TestWseService\Web References\AdesaJasperWse\Reference.cs:line 229 at TestWseService.Form1.buttonRunService_Click(Object sender, EventArgs e) in C:\Documents and Settings\xxx\My Documents\Visual Studio 2005\Projects\TestWseService\Form1.cs:line 42 </code></pre> <p><strong>ERROR MESSAGE WITH WCF</strong></p> <pre><code>The content type multipart/related; type="text/xml"; start="&lt;30ED8FE3004CDA67723CC7164A6CFEEC&gt;"; boundary="----=_Part_209545_389093169.1226526546805" 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 1024 bytes of the response were: Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) </code></pre> <p><strong>Request (with Text Message Encoding):</strong></p> <pre><code>POST /jasperserver-pro/services/repository HTTP/1.1 Content-Type: text/xml; charset=utf-8 VsDebuggerCausalityData: uIDPo7V2+runH+xGudbec7ueUU8AAAAA7H9vL3stlkCBofMgLa5DWkQOHHpBdy1Ek6P6nXx7FpsACQAA SOAPAction: "" Authorization: Basic amFzcGVyYWRtaW46akBzcDNyQGRtJW4= Host: reports.dev.xxx.com Content-Length: 789 Expect: 100-continue &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;q1:runReport xmlns:q1="http://axis2.ws.jasperserver.jaspersoft.com"&gt;&lt;requestXmlString xsi:type="xsd:string"&gt;&amp;lt;request operationName="runReport" locale="en"&amp;gt;&amp;#xD; &amp;lt;argument name="RUN_OUTPUT_FORMAT"&amp;gt;HTML&amp;lt;/argument&amp;gt;&amp;#xD; &amp;lt;resourceDescriptor name="" wsType="" uriString="/BusinessIntelligence/MOS/Reports/dotnettest" isNew="false"&amp;gt;&amp;#xD; &amp;lt;label&amp;gt;null&amp;lt;/label&amp;gt;&amp;#xD; &amp;lt;parameter name="testparam"&amp;gt;1&amp;lt;/parameter&amp;gt;&amp;#xD; &amp;lt;/resourceDescriptor&amp;gt;&amp;#xD; &amp;lt;/request&amp;gt;&lt;/requestXmlString&gt;&lt;/q1:runReport&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt; </code></pre> <p><strong>Response (with Text Message Encoding):</strong></p> <pre><code>HTTP/1.1 200 OK Date: Wed, 12 Nov 2008 21:49:04 GMT Server: IBM_HTTP_Server Surrogate-Control: no-store Set-Cookie: JSESSIONID=0000z5pH1xEMyulueASctjru2qe:13kftunf6; Path=/ Expires: Thu, 01 Dec 1994 16:00:00 GMT Cache-Control: no-cache="set-cookie, set-cookie2" Content-Length: 2580 Content-Type: multipart/related; type="text/xml"; start="&lt;30ED8FE3004CDA67723CC7164A6CFEEC&gt;"; boundary="----=_Part_209545_389093169.1226526546805" Content-Language: en-US ------=_Part_209545_389093169.1226526546805 Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: binary Content-Id: &lt;30ED8FE3004CDA67723CC7164A6CFEEC&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;soapenv:Body&gt;&lt;ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com"&gt;&lt;runReportReturn xsi:type="xsd:string"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;operationResult version=&amp;quot;2.0.1&amp;quot;&amp;gt; &amp;lt;returnCode&amp;gt;&amp;lt;![CDATA[0]]&amp;gt;&amp;lt;/returnCode&amp;gt; &amp;lt;/operationResult&amp;gt; &lt;/runReportReturn&gt;&lt;/ns1:runReportResponse&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt; ------=_Part_209545_389093169.1226526546805 Content-Type: text/html Content-Transfer-Encoding: binary Content-Id: &lt;report&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt; &lt;style type="text/css"&gt; a {text-decoration: none} &lt;/style&gt; &lt;/head&gt; &lt;body text="#000000" link="#000000" alink="#000000" vlink="#000000"&gt; &lt;table width="100%" cellpadding="0" cellspacing="0" border="0"&gt; &lt;tr&gt;&lt;td width="50%"&gt;&amp;nbsp;&lt;/td&gt;&lt;td align="center"&gt; &lt;a name="JR_PAGE_ANCHOR_0_1"/&gt; &lt;table style="width: 595px" cellpadding="0" cellspacing="0" border="0" bgcolor="white"&gt; &lt;tr&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 35px; height: 1px;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 189px; height: 1px;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 253px; height: 1px;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 118px; height: 1px;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td colspan="4"&gt;&lt;img alt="" src="images/px" style="width: 595px; height: 20px;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 35px; height: 30px;"/&gt;&lt;/td&gt; &lt;td valign="middle"&gt;&lt;span style="font-family: Arial; font-size: 12.0px; font-weight: bold;"&gt;The value of the parameter is:&lt;/span&gt;&lt;/td&gt; &lt;td valign="middle"&gt;&lt;span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;"&gt;1&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;img alt="" src="images/px" style="width: 118px; height: 30px;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td colspan="4"&gt;&lt;img alt="" src="images/px" style="width: 595px; height: 20px;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt;&lt;td width="50%"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; ------=_Part_209545_389093169.1226526546805-- </code></pre> <p><strong>Request (with Mtom Message Encoding):</strong></p> <pre><code>POST /jasperserver-pro/services/repository HTTP/1.1 MIME-Version: 1.0 Content-Type: multipart/related; type="application/xop+xml";start="&lt;http://tempuri.org/0&gt;";boundary="uuid:fafcdca7-94f7-4884-a8d4-5c6d50dbe8ef+id=1";start-info="text/xml" VsDebuggerCausalityData: uIDPo+cN2kKX2odFuUVaER0j60gAAAAAmfYaGH7Ow0WQOcwhebh5pqmDl29omcVOtwVGa10IWewACQAA SOAPAction: "" Authorization: Basic amFzcGVyYWRtaW46akBzcDNyQGRtJW4= Host: reports.dev.xxx.com Content-Length: 1031 Expect: 100-continue --uuid:fafcdca7-94f7-4884-a8d4-5c6d50dbe8ef+id=1 Content-ID: &lt;http://tempuri.org/0&gt; Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="text/xml" &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;q1:runReport xmlns:q1="http://axis2.ws.jasperserver.jaspersoft.com"&gt;&lt;requestXmlString xsi:type="xsd:string"&gt;&amp;lt;request operationName="runReport" locale="en"&amp;gt;&amp;#xD; &amp;lt;argument name="RUN_OUTPUT_FORMAT"&amp;gt;HTML&amp;lt;/argument&amp;gt;&amp;#xD; &amp;lt;resourceDescriptor name="" wsType="" uriString="/BusinessIntelligence/MOS/Reports/dotnettest" isNew="false"&amp;gt;&amp;#xD; &amp;lt;label&amp;gt;null&amp;lt;/label&amp;gt;&amp;#xD; &amp;lt;parameter name="testparam"&amp;gt;1&amp;lt;/parameter&amp;gt;&amp;#xD; &amp;lt;/resourceDescriptor&amp;gt;&amp;#xD; &amp;lt;/request&amp;gt;&lt;/requestXmlString&gt;&lt;/q1:runReport&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt; --uuid:fafcdca7-94f7-4884-a8d4-5c6d50dbe8ef+id=1-- </code></pre> <p><strong>Response (with Mtom Message Encoding):</strong></p> <pre><code>HTTP/1.1 500 Internal Server Error Date: Wed, 12 Nov 2008 21:47:42 GMT Server: IBM_HTTP_Server Surrogate-Control: no-store $WSEP: Set-Cookie: JSESSIONID=0000_iMrdp-TnK9FG3jZFzjx_hA:13kftunf6; Path=/ Expires: Thu, 01 Dec 1994 16:00:00 GMT Cache-Control: no-cache="set-cookie, set-cookie2" Content-Length: 12 Connection: close Content-Type: text/html;charset=UTF-8 Content-Language: en-US Error 500: </code></pre> <p>Here is a link that supports the theory that Microsoft does not support mixed encodings:</p> <p><a href="http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/9270913a-ab9f-4097-beef-51d4d69563d7/" rel="noreferrer" title="WSE 3.0: MTOM response mandatory for MTOM request?">WSE 3.0: MTOM response mandatory for MTOM request?</a></p> <p>UHG!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload