2008-11-12 19 views
12

Đây là vấn đề của tôi. Tôi đang nhấn một dịch vụ web (được lưu trữ trên máy chủ dựa trên Java) sẽ chỉ chấp nhận các yêu cầu được mã hóa văn bản, nhưng nó trả về các phản hồi MTOM. Những gì tôi đã tìm thấy là nếu tôi thiết lập dịch vụ web để RequireMtom, nó sẽ gửi một yêu cầu Mtom! Thật không may, máy chủ nghẹt thở trên một yêu cầu Mtom và trả về một lỗi 500. Tuy nhiên, nếu tôi đặt nó thành Mã hóa tin nhắn văn bản, phản hồi sẽ trả về chính xác với phản hồi đa MIME (MTOM) mà lỗi ra khỏi API dịch vụ Web của Microsoft (lỗi mẫu bên dưới). Nó mong đợi một phản ứng được mã hóa văn bản vì yêu cầu được mã hóa văn bản. Tôi muốn RequireMtom chỉ trả lời. bất cứ ai có thể giúp tôi ở đây?Làm cách nào để kết hợp các loại mã hóa thông báo (Text/MTOM) trong ứng dụng Yêu cầu & Trả lời của ứng dụng Dịch vụ Web bằng WCF (hoặc WSE 3)?

Như bạn có thể thấy trong lỗi bên dưới (xảy ra với API dịch vụ web chuẩn, WCF hoặc WSE3), khi tôi gửi yêu cầu bằng mã hóa văn bản, phản hồi sẽ trả về chính xác với tất cả dữ liệu trong một multipart/phản ứng liên quan, nhưng khung cuộn cảm ứng .net!

LỖI THÔNG ĐIỆP VỚI 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 

LỖI THÔNG ĐIỆP VỚI 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) 

Yêu cầu (với tin nhắn văn bản Encoding):

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> 

Response (với tin nhắn văn bản Encoding):

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-- 

Yêu cầu (với MTOM nhắn Encoding):

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-- 

Response (với MTOM nhắn Encoding):

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: 

Dưới đây là một liên kết hỗ trợ lý thuyết cho rằng Microsoft không hỗ trợ mã hóa hỗn hợp:

WSE 3.0: MTOM response mandatory for MTOM request?

UHG!

+1

Hãy coi chừng: WSE đã lỗi thời. WCF nên được sử dụng cho tất cả các phát triển dịch vụ web trong tương lai, và mã WSE hiện tại nên được di chuyển hoặc đã gỡ bỏ ASAP. –

Trả lời

0

Đây là câu trả lời tôi nhận được trên một diễn đàn khác. về cơ bản nó nói rằng vấn đề là với Axis2 ở phía Java. Thật không may, đó không phải là dưới sự kiểm soát của tôi trong trường hợp này.

cherry111 - Được đăng vào Thứ bảy, ngày 15 tháng 11 năm 2008 12:52:08

Bạn cần thay đổi cấu hình trên dịch vụ web Axis2 của bạn. Bạn có thể biết bạn có thể bật MTOM ở hai nơi. Một có trong service.xml và một là trong axis.xml. Java khuyên bạn nên đặt trong service.xml, nhưng .net wse3.0 khách hàng không thích nó. Nếu bạn bật MTOM trong axis.xml, nó sẽ hoạt động.

1

Tôi đã nghiên cứu một chút về điều này và tin xấu là từ điểm WCF xem yêu cầu và phản hồi PHẢI sử dụng cùng một cách mã hóa. Vì vậy, yeah, câu trả lời ở trên là khá chính xác. Bạn phải tổ chức với nhà cung cấp dịch vụ để bật MTOM trên cả yêu cầu và phản hồi. Yêu cầu MTOM sẽ không có bất kỳ tác động nào đối với ứng dụng của anh ta, ngoài việc thay đổi loại mime SOAP, theo như tôi biết.

0

Có WCF có mà yêu cầu bắt buộc và NO, bởi vì bạn có thể làm việc xung quanh nó như tôi đã làm.

Tôi đã viết một MultiContentTypeMessageEncoder gói gọn 3 bộ mã hóa văn bản, mtom và fi khác nhau. Tôi cũng có kế hoạch đóng gói bộ mã hóa gpb nếu có thể và nếu có lý do chính đáng để làm như vậy, trong tương lai

-2

[WSE 3.0] Bạn có thể xác định một lớp mới kế thừa từ đối tượng proxy WSE3 của bạn phương pháp GetWebResponse.

Trong phương pháp GetWebResponse, bạn có thể chỉ cần chọn nếu bạn muốn sử dụng mã hóa mtom theo kiểu nội dung của phản hồi.

Sau đó, bạn phải sử dụng lớp proxy này thay vì lớp proxy đã tạo.

PS: Lớp proxy WSE3 phải được tạo bằng cách sử dụng wsewsdl3 làm WebClient (thêm tùy chọn này/loại: webClient vào dòng khen).

Tham chiếu: http://www.codeproject.com/Tips/46257/Solution-to-WSE-error-for-WSE-clients-needing.