2013-02-23 4 views
1

이 게시물이 너무 오래 느껴지면 미리 사과드립니다. 그러나 1) 이것이 나의 첫 번째 게시물과 2) 나는 정말로 강을 넘어 숲을 통해 이것을 알아 내려고 노력했다.BancBox SOAP API getClient - WCF 클라이언트 인프라를 사용하여 호출이 실패합니다.

Visual Studio 2012의 서비스 참조 추가 기능은 (분명히) 잘못된 SOAP 메시지를 생성하는 프록시를 생성합니다. 직렬화 또는 프록시 유형을 장식하는 방법과 관련이 있다고 생각하지만,이를 파악할 수는 없습니다. 도움을 많이 주시면 감사하겠습니다.

상세 1. 내 환경은 비주얼 스튜디오 2012와 나는 https://sandbox-api.bancbox.com/v1/BBXPort?wsdl에 서비스 참조와 .NET 4.5 클래스 라이브러리를 만들었습니다. getClient() 함수를 호출하려고합니다. 여기에 정의되어 있습니다. (http://www.bancbox.com/api/view/45)

코드는 다음과 같습니다

public void GetClient() 

{ 
    // create an instance of the service reference proxy class 
    var bbx=newBBXClient(); 
    bbx.ChannelFactory.Endpoint.Behaviors.Remove<System.ServiceModel.Description.ClientCredentials>(); 
    bbx.ChannelFactory.Endpoint.Behaviors.Add(new CustomCredentials()); 

    bbx.ClientCredentials.UserName.UserName="MY_USERNAME"; 
    bbx.ClientCredentials.UserName.Password="MY_PASSWORD"; 

    var customerId=newid { 
      subscriberReferenceId="44XX33YY" 
    }; 

    var request=newgetClientRequest { 
      subscriberId=MY_SUBSCRIBER_ID, 
      clientId=customerId 
    }; 

    var response=bbx.getClient(request); 
} 

상세 SoapUI를 통해 웹 서비스에 2 내가 만든 많은 성공 통화. 성공적인 SoapUI 생산 SOAP 메시지는이

<soapenv:Envelope xmlns:sch="schema.bancbox.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Header> 
    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
     <wsse:UsernameToken wsu:Id="UsernameToken-11"> 
      <wsse:Username>MY_USERNAME</wsse:Username> 
      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MY_PASSWORD</wsse:Password> 
      <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">tRLo6AlRKl+/rULiKq6A6g==</wsse:Nonce> 
      <wsu:Created>2013-02-22T18:32:02.204Z</wsu:Created> 
     </wsse:UsernameToken> 
    </wsse:Security> 
</soapenv:Header> 
<soapenv:Body> 
    <sch:getClient> 
     <getClientRequest> 
      <subscriberId>MY_SUBSCRIBER_ID</subscriberId> 
       <clientId> 
        <!--Optional:--> 
        <subscriberReferenceId>44XX33YY</subscriberReferenceId> 
       </clientId> 
     </getClientRequest> 
    </sch:getClient> 
</soapenv:Body> 
</soapenv:Envelope> 

상세 3. 당 피들러처럼, 내 실패 SOAP 메시지는 GetClient을 (실행시 위의 SOAP 메시지가 생성됩니다이

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
<s:Header> 
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPozcAgEH0QhJHloqMBWUf3mAAAAAA5wy3enJkDUGU8IaMUCFyEjzfL+1Uez1HhAvEeFpJ+30ACQAA</VsDebuggerCausalityData> 
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <o:UsernameToken u:Id="uuid-6e1c9f81-0651-41f7-b659-26b191bf7e13-1" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
      <o:Username>MY_USERNAME</o:Username> 
      <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MY_PASSWORD</o:Password> 
      <o:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">hGggJkxurSkHQ3MKoeBK6AmEHNs=</o:Nonce> 
      <u:Created>2013-02-23T11:24:47.663Z</u:Created> 
     </o:UsernameToken> 
    </o:Security> 
</s:Header> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <getClient xmlns="schema.bancbox.com"> 
     <getClientRequest xmlns=""> 
      <subscriberId>MY_SUBSCRIBER_ID</subscriberId> 
      <clientId> 
       <subscriberReferenceId>XX55YY22</subscriberReferenceId> 
      </clientId> 
     </getClientRequest> 
    </getClient> 
</s:Body> 
</s:Envelope> 

처럼) 방법. GetClient는 다음 Exception을 발생시킵니다. 내가 SoapUI를 사용하여 동일한 실패 메시지를 재생할 때

System.ServiceModel.FaultException 
Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'getClientRequest' to a type definition for element 'getClientRequest'. 

, 나는 다음과 같은 응답을 얻을 : 내 연구를 바탕으로

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
<soap:Body> 
    <soap:Fault> 
     <faultcode>soap:Client</faultcode> 
     <faultstring>Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'getClientRequest' to a type definition for element 'getClientRequest'. </faultstring> 
    </soap:Fault> 
</soap:Body> 
</soap:Envelope> 

상세 4.을,이 다른 쪽 끝에있는 서버가 있음을 나타냅니다 Apache CXS. 그것은 내 SOAP 요청에 질식합니다. 그래서 나는 내 SOAP 메시지를 가지고 노는 것을 시작했고 SoapUI를 통해 그것을 제출하기 시작했다.

성공적인 메시지의 첫 번째 눈부신 거리와 메시지를 실패의 나는

<sch:getClient> 
    <getClientRequest> 

<getClient xmlns="schema.bancbox.com"> 
    <getClientRequest xmlns=""> 

를 FAIL

성공이 라인 그래서 내가했던 첫 번째 일은 내 getClientRequest을했다 성공적인 태그와 동일한 태그.

<getClient xmlns="schema.bancbox.com"> 
    <getClientRequest> 

이렇게하면 다음과 같은 응답이 나타납니다.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
<soap:Body> 
    <soap:Fault> 
     <faultcode>soap:Server</faultcode> 
     <faultstring>Found element {schema.bancbox.com}getClientRequest but could not find matching RPC/Literal part</faultstring> 
    </soap:Fault> 
</soap:Body> 
</soap:Envelope> 

다음으로 수행 한 작업은 getClient 태그에 스키마가 할당되는 방식을 변경하는 것입니다.

하기 전에

<getClient xmlns="schema.bancbox.com"> 

<s:Envelope xmlns:bb="schema.bancbox.com" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
. . . 
    <bb:getClient> 
     <getClientRequest> 
. . . 
    </bb:getClient> 

후 결과 SOAP 메시지는 다음과 같습니다과 성공이다.

<s:Envelope xmlns:bb="schema.bancbox.com" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
<s:Header> 
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPozcAgEH0QhJHloqMBWUf3mAAAAAA5wy3enJkDUGU8IaMUCFyEjzfL+1Uez1HhAvEeFpJ+30ACQAA</VsDebuggerCausalityData> 
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <o:UsernameToken u:Id="uuid-6e1c9f81-0651-41f7-b659-26b191bf7e13-1" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
      <o:Username>MY_USERNAME</o:Username> 
      <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MY_PASSWORD</o:Password> 
      <o:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">hGggJkxurSkHQ3MKoeBK6AmEHNs=</o:Nonce> 
      <u:Created>2013-02-23T11:24:47.663Z</u:Created> 
     </o:UsernameToken> 
    </o:Security> 
</s:Header> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <bb:getClient> 
     <getClientRequest> 
      <subscriberId>MY_SUBSCRIBER_ID</subscriberId> 
      <clientId> 
       <subscriberReferenceId>XX55YY22</subscriberReferenceId> 
      </clientId> 
     </getClientRequest> 
    </bb:getClient> 
</s:Body> 
</s:Envelope> 

그래서 백만 달러짜리 질문은 왜 그런가?

* .NET 프록시 클래스는 왜 SOAP 메시지를 직렬화합니까?

* 어떻게 수정합니까? 프록시가 위의 SOAP 메시지로 직렬화 할 수 있습니까? 어떻게 serializer가 Envelop의 메시지 네임 스페이스에 대한 속기를 정의한 다음 메시지 태그에서 속기를 사용하도록 할 수 있습니까?

참고로이 시점까지는 WCF WSE 문제를 여러 번 해결해야하며 Rich Stahls 블로그에 너무 아낌없이 제공하는 솔루션을 구현해야했습니다. 나는 연결을 배치 할 것이나 외관상으로는 나는 충분한 rep가 없다.

답변

0

내가 알기로는, WCF가 생성하는 SOAP 메시지는 구문 상 올바르다. 그러나 Java CXF 웹 서비스는 받아 들일 SOAP 메시지와 관련하여 매우 엄격합니다. Force WCF to create an xml namespace alias in client proxy을 :

WCF 프록시에 의해 생성 된 SOAP 메시지의 동작 노드의 XML 네임 스페이스 정의에 대한 별칭을 설정하는 특정 문제에 대한 해결책은 사용자 정의 메시지 관리자 여기에 자세히 설명되어 구현이 포함됩니다.

이것은 내 문제를 완전히 해결했습니다.