我如何混合邮件的编码类型(文本/ MTOM)的要求和放大器;使用WCF(或WSE 3)的Web服务客户端应用程序的响应?放大器、应用程序、客户端、文本

2023-09-03 09:48:36 作者:无法忘却的旧爱

下面是我的问题。我打一个Web服务(托管基于Java的服务器),将只接受文字连接codeD的要求,但它返回MTOM响应。我发现的是,如果我设置Web服务RequireMtom,它发送一个MTOM的要求!不幸的是,服务器扼流圈上MTOM请求,并返回500错误。不过,如果我将其设置为短信编码,响应回来正确与一个多部分MIME(MTOM)响应的错误出在微软的Web服务API(下抽样误差)。该公司预计,文本连接codeD响应,因为请求是文字连接codeD。我想RequireMtom上的应答。任何人都可以帮助我在这里?

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?

正如你可以在下面的错误(发生与标准的Web服务API,周转基金或WSE3)看,当我发送的文字编码的请求,响应返回正确的,在一个多部分的所有数据/相关的回应,但.NET框架电抗器!的

使用WSE的错误信息:

Client found response content type of 'multipart/related; type="text/xml"; start="<1AE0B46A85B0186B5D136D12E1EE286E>";  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

使用WCF的错误信息

The content type multipart/related; type="text/xml"; start="<30ED8FE3004CDA67723CC7164A6CFEEC>";    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)

请求(用短信编码):

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

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><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"><q1:runReport xmlns:q1="http://axis2.ws.jasperserver.jaspersoft.com"><requestXmlString xsi:type="xsd:string">&lt;request operationName="runReport" locale="en"&gt;&#xD;
&lt;argument name="RUN_OUTPUT_FORMAT"&gt;HTML&lt;/argument&gt;&#xD;
&lt;resourceDescriptor name="" wsType="" uriString="/BusinessIntelligence/MOS/Reports/dotnettest" isNew="false"&gt;&#xD;
&lt;label&gt;null&lt;/label&gt;&#xD;
&lt;parameter name="testparam"&gt;1&lt;/parameter&gt;&#xD;
&lt;/resourceDescriptor&gt;&#xD;
&lt;/request&gt;</requestXmlString></q1:runReport></s:Body></s:Envelope>

响应(用短信编码):

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="<30ED8FE3004CDA67723CC7164A6CFEEC>";   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: <30ED8FE3004CDA67723CC7164A6CFEEC>

<?xml version="1.0" encoding="utf-8"?><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"><soapenv:Body><ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com"><runReportReturn xsi:type="xsd:string">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;operationResult version=&quot;2.0.1&quot;&gt;
    &lt;returnCode&gt;&lt;![CDATA[0]]&gt;&lt;/returnCode&gt;
&lt;/operationResult&gt;
</runReportReturn></ns1:runReportResponse></soapenv:Body></soapenv:Envelope>
------=_Part_209545_389093169.1226526546805
Content-Type: text/html
Content-Transfer-Encoding: binary
Content-Id: <report>

<html>
<head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <style type="text/css">
    a {text-decoration: none}
  </style>
</head>
<body text="#000000" link="#000000" alink="#000000" vlink="#000000">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td width="50%">&nbsp;</td><td align="center">

<a name="JR_PAGE_ANCHOR_0_1"/>
<table style="width: 595px" cellpadding="0" cellspacing="0" border="0" bgcolor="white">
<tr>
  <td><img alt="" src="images/px" style="width: 35px; height: 1px;"/></td>
  <td><img alt="" src="images/px" style="width: 189px; height: 1px;"/></td>
  <td><img alt="" src="images/px" style="width: 253px; height: 1px;"/></td>
  <td><img alt="" src="images/px" style="width: 118px; height: 1px;"/></td>
</tr>
<tr valign="top">
  <td colspan="4"><img alt="" src="images/px" style="width: 595px; height: 20px;"/></td>
</tr>
<tr valign="top">
  <td><img alt="" src="images/px" style="width: 35px; height: 30px;"/></td>
  <td valign="middle"><span style="font-family: Arial; font-size: 12.0px; font-weight: bold;">The value of the parameter is:</span></td>
  <td valign="middle"><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">1</span></td>
  <td><img alt="" src="images/px" style="width: 118px; height: 30px;"/></td>
</tr>
<tr valign="top">
  <td colspan="4"><img alt="" src="images/px" style="width: 595px; height: 20px;"/></td>
</tr>
</table>

</td><td width="50%">&nbsp;</td></tr>
</table>
</body>
</html>

------=_Part_209545_389093169.1226526546805--

请求(与MTOM消息编码):

POST /jasperserver-pro/services/repository HTTP/1.1
MIME-Version: 1.0
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";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: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><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"><q1:runReport xmlns:q1="http://axis2.ws.jasperserver.jaspersoft.com"><requestXmlString xsi:type="xsd:string">&lt;request operationName="runReport" locale="en"&gt;&#xD;
&lt;argument name="RUN_OUTPUT_FORMAT"&gt;HTML&lt;/argument&gt;&#xD;
&lt;resourceDescriptor name="" wsType="" uriString="/BusinessIntelligence/MOS/Reports/dotnettest" isNew="false"&gt;&#xD;
&lt;label&gt;null&lt;/label&gt;&#xD;
&lt;parameter name="testparam"&gt;1&lt;/parameter&gt;&#xD;
&lt;/resourceDescriptor&gt;&#xD;
&lt;/request&gt;</requestXmlString></q1:runReport></s:Body></s:Envelope>
--uuid:fafcdca7-94f7-4884-a8d4-5c6d50dbe8ef+id=1--

响应(与MTOM消息编码):

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:

下面是支持的理论,微软不支持混合编码的链接:

Here is a link that supports the theory that Microsoft does not support mixed encodings:

WSE 3.0:MTOM对MTOM的请求响应强制性

UHG!

推荐答案

是的,你可以发送短信,并得到一个MTOM的答复(或反之亦然)与WCF。

Yes you can send a text message and get an mtom reply(or vise versa)with WCF.

见...

的http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/480f1bc4-1fc4-40e9-a2ed-efcf3009d6ef