13

これが私の問題です。テキスト エンコードされたリクエストのみを受け入れる Web サービス (Java ベースのサーバーでホストされている) にヒットしていますが、MTOM レスポンスを返します。私が見つけたのは、Web サービスを RequireMtom に設定すると、Mtom リクエストが送信されるということです。残念ながら、サーバーは Mtom 要求で停止し、500 エラーを返します。ただし、テキスト メッセージ エンコーディングに設定すると、応答は、Microsoft Web サービス API でエラーになるマルチパート MIME (MTOM) 応答で正しく返されます (以下のサンプル エラー)。リクエストがテキスト エンコードされているため、テキスト エンコードされたレスポンスが必要です。応答のみに RequireMtom を適用したいと思います。誰でもここで私を助けることができますか?

以下のエラー (標準の Web サービス API、WCF、または 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: 

Microsoft が混合エンコーディングをサポートしていないという理論をサポートするリンクを次に示します。

WSE 3.0: MTOM 要求には MTOM 応答が必須ですか?

うーん!

4

5 に答える 5

8

はい、WCFを使用してテキストメッセージを送信し、mtom応答(またはその逆)を取得できます。

見る...

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

于 2009-11-25T19:32:52.427 に答える
2

私はこれについて少し調査しましたが、悪いニュースは、WCF の観点からすると、要求と応答は同じエンコンディングを使用する必要があるということです。そうです、上記の答えはかなり正しいです。リクエストとレスポンスの両方で MTOM を有効にするには、サービス プロバイダーと連携する必要があります。私の知る限り、MTOM リクエストは、SOAP MIME タイプの変更を除けば、彼のアプリケーションには何の影響も与えません。

于 2008-11-20T09:04:54.620 に答える
1

はい、WCFにはその義務付けられた要件があり、NOです。私のように回避できるからです。

3 つの異なるエンコーダ text、mtom、fi をカプセル化する MultiContentTypeMessageEncoder を作成しました。また、可能であればgpbエンコーダーをカプセル化する予定であり、そうする正当な理由がある場合は、将来的に

于 2010-03-09T10:37:49.637 に答える
1

これは私が別のフォーラムで得た返信です。基本的に、問題は Java 側の Axis2 にあると言われています。残念ながら、この場合、それは私の管理下にありません。

cherry111 - 投稿日: 2008 年 11 月 15 日 (土) 12:52:08 AM

AXIS2 Web サービスの構成を変更する必要があります。MTOM を 2 か所で有効にできることはご存知かもしれません。1 つは service.xml にあり、もう 1 つは axis.xml にあります。Java は service.xml に設定することを推奨していますが、.net wse3.0 クライアントはそれを好みません。axis.xml で MTOM を有効にすると、動作するはずです。

于 2008-11-18T05:01:39.837 に答える
0

[WSE 3.0] 単一のオーバーライド メソッド GetWebResponse を使用して、WSE3 プロキシ オブジェクトから継承する新しいクラスを定義できます。

GetWebResponse メソッドでは、応答のコンテンツ タイプに応じて mtom エンコーディングを使用するかどうかを簡単に選択できます。

その後、生成されたプロキシ クラスの代わりにこのプロキシ クラスを使用する必要があります。

PS: WSE3 プロキシ クラスは、wsewsdl3 を WebClient として使用して生成する必要があります (このオプション /type:webClient をコマンド ラインに追加します)。

参照: http://www.codeproject.com/Tips/46257/Solution-to-WSE-error-for-WSE-clients-needing

于 2015-10-06T08:41:01.680 に答える