WCF (또는 WSE 3)를 사용하여 웹 서비스 클라이언트 응용 프로그램의 요청 및 응답에서 메시지 인코딩 유형 (텍스트/MTOM)을 어떻게 혼합합니까?

StackOverflow https://stackoverflow.com/questions/284149

문제

여기 내 문제가 있습니다. 텍스트 인코딩 된 요청 만 수락하는 웹 서비스 (Java 기반 서버에서 호스팅 된)를 치고 있지만 MTOM 응답을 반환합니다. 내가 찾은 것은 웹 서비스를 요구 사항을 요구하면 MTOM 요청을 보냅니다! 불행히도 서버는 MTOM 요청을 질식시키고 500 오류를 반환합니다. 그러나 문자 메시지 인코딩으로 설정하면 Microsoft Web Service API (아래 샘플 오류)를 오류하는 MTOM (Multipart MIME) 응답으로 응답이 올바르게 돌아옵니다. 요청이 텍스트 인코딩되었으므로 텍스트 인코딩 된 응답이 기대됩니다. 응답에 대해서만 요구하고 싶습니다. 누구든지 여기서 나를 도울 수 있습니까?

아래 오류에서 볼 수 있듯이 (표준 웹 서비스 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 응답 의무?

어!

도움이 되었습니까?

해결책

예, 문자 메시지를 보내고 WCF로 MTOM 답장 (또는 Vise Versa)을받을 수 있습니다.

보다...

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

다른 팁

나는 이것에 대해 조금 조사했고 나쁜 소식은 WCF의 관점에서 요청과 응답이 동일한 엔코딩을 사용해야한다는 것입니다. 예, 위의 대답은 매우 정확합니다. 요청과 응답 모두에서 MTOM을 활성화하려면 서비스 제공 업체와 함께 구성해야합니다. MTOM 요청은 내가 아는 한 비누 마임 유형을 변경하는 것 외에도 응용 프로그램에 아무런 영향을 미치지 않습니다.

다음은 다른 포럼에서받은 답장입니다. 기본적으로 문제는 Java 쪽의 Axis2와 관련이 있다고 말합니다. 불행히도, 그것은이 경우에 내 통제하에 있지 않습니다.

Cherry111- 2008 년 11 월 15 일 토요일에 게시 된 12:52:08 AM

Axis2 웹 서비스에서 구성을 변경해야합니다. 두 곳에서 MTOM을 활성화 할 수 있다는 것을 알 수 있습니다. 하나는 서비스에 있고 다른 하나는 Axis.xml에 있습니다. Java는 service.xml로 설정할 것을 권장하지만 .NET wse3.0 클라이언트는 마음에 들지 않습니다. Axis.xml에서 mtom을 활성화하면 작동해야합니다.

예 WCF는 내가 한 것처럼 일을 할 수 있기 때문에 의무적 인 요구 사항을 가지고 있습니다.

나는 3 개의 다른 인코더 텍스트, mtom 및 fi를 캡슐화하는 multicontentTypeSageEncoder를 썼습니다. 또한 가능하면 GPB 인코더를 캡슐화 할 계획이며 앞으로 그럴만 한 이유가 있다면

WSE 3.0] 단일 재정의 메소드 GetWebResponse로 WSE3 프록시 오브젝트에서 상속되는 새 클래스를 정의 할 수 있습니다.

getwebresponse 메소드에서 응답의 내용 유형에 따라 MTOM 인코딩을 사용하려는 경우 간단히 선택할 수 있습니다.

그 후에는 생성 된 클래스 대신이 프록시 클래스를 사용해야합니다.

추신 : WSE3 프록시 클래스는 WSEWSDL3을 웹 클라이언트로 사용하여 생성되어야합니다 (이 옵션 /유형 추가 : WebClient 추가 기준 라인에).

참조:http://www.codeproject.com/tips/46257/solution-to-wse-error-for-wse-clients-needing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top