2013-06-06 1 views
0

배경 정보 : C#에서 웹 서비스를 사용하는 클라이언트 빌드. svcutil을 사용하여 프록시 클래스를 자동으로 생성합니다. 웹 서비스는 MTOM을 통해 PDF 첨부 파일을 보내도록 설정되어, 나는 그렇게하려고 프록시에서 API 호출을 사용할 때, 나는 다음과 같은 오류 얻을 : 나는 '하는 ...SOAP/MTOM : VS 생성 프록시 클래스 문제 및 PDF 첨부 파일 처리

Client found response content type of 'multipart/related; boundary="MIMEBoundaryurn_uuid_5D7E9AC12266BFFBDB1370543444063"; start-info="text/xml"; type="text/xml"; start="<0.urn:uuid:[email protected]>"', but expected 'text/xml'.

을 클라이언트가 MTOM에 대해 올바르게 구성되지 않았 음을 의미합니다. 좋아, 멋지다, 그것을 만들기 위해 설정을 변경하는 방법에 대한 몇 가지 예가있다. 여기에 제가 위로 올라가고 있습니다. - 지금까지 발견 한 모든 예제에는 설정 파일이 광산 설치 방법과 다르게 매핑되어 있습니다. 예제는 system.serviceModel 섹션에 두 개의 항목으로 구성됩니다. 하나는 바인딩 용이고 다른 하나는 엔드 포인트 주소를 포함하는 클라이언트 엔드 포인트 용입니다. 내 자동 생성 된 설정은 주소를 applicationSettings에 집어 넣고 혼란 스럽습니다.

예 : :(여기서 그들은 나란히 있습니다

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_IUpload" messageEncoding="Mtom"/> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/ServiceModelSamples/service.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUpload" contract="IUpload"> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 

광산 :

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost:8080/getStiDoc", RequestNamespace="http://www.<redacted>.com/ws/schemas", ResponseNamespace="http://www.<redacted>.com/ws/schemas", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] 
     [return: System.Xml.Serialization.XmlElementAttribute("doc", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="base64Binary", IsNullable=true)] 
     public byte[] getDoc([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string username, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="integer", IsNullable=true)] string id) { 
      object[] results = this.Invoke("getDoc", new object[] { 
         username, 
         id}); 
      return ((byte[])(results[0])); 
     } 
:

여기
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=----------------" > 
      <section name="TWS.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=----------------" requirePermission="false" /> 
     </sectionGroup> 
     </configSections> 
     <applicationSettings> 
     <TWS.Properties.Settings> 
      <setting name="TWS_WebService_WsApiService" serializeAs="String"> 
      <value>https://www.<redacted>.com/services/WsApiService/</value> 
      </setting> 
     </TWS.Properties.Settings> 
     </applicationSettings> 
    </configuration> 

는 API 자체는 프록시 클래스에서 설정 호출 방법

제 질문은 이것입니다 : 설정 파일을 어떻게 설정했는지, 적절한 바인딩을 추가하여 어떻게 보이게해야합니까? Base64 바이너리 대신 MTOM을 사용합니까?

답변

0

결국 내 대답을 찾았습니다. 프록시 클래스를 올바르게 설정하려면 (즉, WCF 호환 형식), 명령 줄을 통해 svcutil을 사용하여 WSDL을 프록시 클래스로 변환해야했습니다. 그렇게 한 후에 MTOM에 메시지 바인딩을 설정할 수있었습니다. 여전히 인증서로 인증하는 데 문제가 있지만 그다지 문제는 아닙니다.