2014-12-10 17 views
1

WSDL -URL에서 wsdl.exe을 통해 C# 프록시 클래스를 만들었습니다. 내가 제어하지 않는 웹 응용 프로그램의 컨텍스트에서이 프록시 클래스를 사용하고 있습니다 (따라서 web.conf 또는 이와 유사한 메서드를 변경할 수있는 방법이 없습니다). 나는 또한 내가 말하는 웹 서비스에서 어떤 것도 변경할 수 없다.SoapHttpClientProtocol에서 예기치 않은 콘텐츠 형식을받습니다.

내가 읽은 바로는
Client found response content type of 'multipart/related; type="application/xop+xml"; 
boundary="uuid:5c314128-0dc0-4cad-9b1a-dc4a3e5917bb"; start="<[email protected]>"; 
start-info="application/soap+xml"', but expected 'application/soap+xml'. 

,이 웹 서비스에 의해 사용되는 MTOM에 문제가 있습니다 :

웹 서비스를 호출

, 나는 다음과 같은 예외를받을 수 있습니다. 이제 수업을 MTOM을 수락하라고 말하려고했으나 찾은 건 web.conf의 구성입니다.

프록시 클래스는 SoapHttpClientProtocol에서 파생 된이처럼 보이는

(관련 부분) :

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]  
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Web.Services.WebServiceBindingAttribute(Name = "myrequestSoapBinding", Namespace = "http://namespace.of.company.of.webservice/")] 
public class myrequest : System.Web.Services.Protocols.SoapHttpClientProtocol 
{ 
    public myrequest(string url) 
    { 
     this.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;    
     this.Url = url; 
    } 

    [return: System.Xml.Serialization.XmlElementAttribute("return", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, DataType = "base64Binary")] 
    public byte[] getDocuments([System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, DataType = "base64Binary")] byte[] input) 
    { 
     try 
     { 
      object[] results = this.Invoke("getDocuments", new object[] { 
       input}); 
      return ((byte[])(results[0])); 
     } 
     catch (Exception ex) 
     { 
      var realResponse = StripResponse(ex.Message); 
      return Encoding.UTF8.GetBytes(realResponse.ToString()); 
     } 
    } 
} 

getDocumentstry ... catch 예외 Message 밖으로 '진짜'서비스 응답을 얻는 해키 해결 방법입니다 - 어떤 이걸 어떻게 구현하고 싶지는 않습니다.

내 질문은 : MTOM 응답을 받아들이도록 프록시 클래스에서 바인딩을 변경하는 방법이 있습니까?

답변

0

도움을주기 위해 수행 한 소량의 연구에서 을 수행하면이 웹 설정에 액세스 할 수 있으며 (내가 알지는 못하는) MTOM을 켠 다음 Visual 스튜디오 프록시 클래스를 생성합니다 :

  1. SoapHttpClientProtocol 및 파생 표준을;
  2. "WSE"Microsoft.Web.Services3.WebServicesClientProtocol

그것은 MTOM을 받아 들일 수있는 WebServicesClientProtocol의 구현에서 파생 클래스 이름에 추가와 WSE 하나. WSDL에서 WebServicesClientProtocol에서 파생 된 프록시를 만들려면 top of this MSDN article의 Note를 따르십시오.

이렇게하면 문제가 해결되기를 바랍니다.