2013-03-10 5 views
1

제공된 로그온 함수를 통해 affilinet 웹 서비스에 로그온하려고합니다. 나는 Rails 3 환경 (3.0.x)에서 일하고있다. 나는 버전 2의 레일스 보석 Savon에 루비를 사용하는데, 차례로 affilinet에 연결하기 위해 비누를 사용합니다.
가장 최근의 wsdl은 여기 https://api.affili.net/V2.0/Logon.svc?wsdl에서 찾을 수 있습니다.
내 코드는 다음과 같습니다RoR : savon (ruby on rails)을 사용하여 affilinet 웹 서비스 (로그온 기능)를 연결할 때 오류 발생 -> 역 직렬화 실패

client = Savon.client do 
    wsdl "https://api.affili.net/V2.0/Logon.svc?wsdl" 
end 
message = {'Username' => 'username', 'Password' => 'password', 'WebServiceType' => 'Publisher'} 
response = client.call(:logon, :message => message) 

Savon에 의해 생성 된 요청을 :

<?xml version="1.0" encoding="UTF-8"?> 
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://affilinet.framework.webservices/Svc" xmlns:ins3="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ins2="http://affilinet.framework.webservices/types" xmlns:ins1="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF" xmlns:ins0="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <env:Body> 
    <tns:LogonRequestMsg> 
     <tns:Password>password</tns:Password> 
     <tns:WebServiceType>Publisher</tns:WebServiceType> 
     <tns:Username>username</tns:Username> 
    </tns:LogonRequestMsg> 
    </env:Body> 
</env:Envelope> 

나는이 (오류) 응답을 얻을 웹 서비스에 요청 전송 :

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
     <s:Fault> 
     <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode> 
     <faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://affilinet.framework.webservices/Svc:LogonRequestMsg. The InnerException message was 'Error in line 1 position 775. 'EndElement' 'LogonRequestMsg' from namespace 'http://affilinet.framework.webservices/Svc' is not expected. Expecting element 'Username | Password | WebServiceType'.'. Please see InnerException for more details.</faultstring> 
     <detail> 
      <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
      <HelpLink i:nil="true"/> 
      <InnerException> 
       <HelpLink i:nil="true"/> 
      <InnerException i:nil="true"/> 
      <Message>Error in line 1 position 775. 'EndElement' 'LogonRequestMsg' from namespace 'http://affilinet.framework.webservices/Svc' is not expected. Expecting element 'Username | Password | WebServiceType'.</Message> 
      <StackTrace> at System.Runtime.Serialization.XmlObjectSerializerReadContext.ThrowRequiredMemberMissingException(XmlReaderDelegator xmlReader, Int32 memberIndex, Int32 requiredIndex, XmlDictionaryString[] memberNames)&#xD; ... (loads more) ... 
      </StackTrace> 
      <Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type> 
      </ExceptionDetail> 
     </detail> 
     </s:Fault> 
    </s:Body> 
</s:Envelope> 

어떤 아이디어가 잘못 되었나요?

편집 :

soapUI의 요청은 다음과 같습니다

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:svc="http://affilinet.framework.webservices/Svc" xmlns:typ="http://affilinet.framework.webservices/types"> 

<soapenv:Header/> 
<soapenv:Body> 
    <svc:LogonRequestMsg> 
    <!--Optional:--> 
    <typ:Username>username</typ:Username> 
    <!--Optional:--> 
    <typ:Password>password</typ:Password> 
    <typ:WebServiceType>Publisher</typ:WebServiceType> 
    <!--Optional:--> 
    <typ:DeveloperSettings> 
     <!--Optional:--> 
     <typ:SandboxPublisherID>?</typ:SandboxPublisherID> 
    </typ:DeveloperSettings> 
    <!--Optional:--> 
    <typ:ApplicationSettings> 
     <!--Optional:--> 
     <typ:ApplicationID>?</typ:ApplicationID> 
     <!--Optional:--> 
     <typ:DeveloperID>?</typ:DeveloperID> 
    </typ:ApplicationSettings> 
    </svc:LogonRequestMsg> 
</soapenv:Body> 
</soapenv:Envelope> 

요청에 아마 차이 (soapUI Savon에 의해에 의해 생성)의 열쇠!? 특히 다른 네임 스페이스 : svc/typ vs. env/tns. 어떤 아이디어? Savon에게 LogonRequestMsg에 svc 네임 스페이스를 사용하도록 어떻게 말할 수 있습니까?

+0

내가 매우 SsoapUI를 설치하는 것이 좋습니다 SOAP 계층 (http://sourceforge.net/projects/soapui/files/를 디버깅하려면). 그런 다음 SOAP 메시지를 테스트하여 * 해당 * 레이어가 작동하는지 확인할 수 있습니다. 그래도 필요한 경우 Savon을 처리 할 수 ​​있습니다. 당신이 묘사하는 문제는 (아직) Savon과 관련이 없습니다. –

답변

3

Affili.net의 WSDL을 보면 사용자 이름, 암호, WebserviceType 등의 네임 스페이스가 잘못되었음을 알 수 있습니다.

EDITED 네임 스페이스에 대한 다른 예제를 살펴본 후. Username, Password 및 WebServiceType은 ins2 = "http : //affilinet.framework.webservices/types"네임 스페이스에 정의되어 있으며이 경우 ins2로 태그 지정됩니다. 이

client = Savon.client do 
    wsdl "https://api.affili.net/V2.0/Logon.svc?wsdl" 
end 
message = {'ins2:Username' => 'username', 
      'ins2:Password' => 'password', 
      'ins2:WebServiceType' => 'Publisher'} 

response = client.call(:logon, :message => message) 
+0

네임 스페이스를 변경해도 도움이되지 않았습니다. soapUI는 Username, Password 및 WebServiceType의 네임 스페이스가 'typ'라고 말합니다. ... 암호 게시자 ... 하지만 '일반'으로 변경하면 도움이되지 않습니다. Savon이 실제로 WSDL을 잘못 처리하고 있습니까? – user2148956

+0

이유가 무엇이든간에 Savon은 네임 스페이스에 soapUI와 다른 이름을 부여합니다. 원시 wsdl 문서를 살펴보면 메시지 유형으로 "tns : LogonRequest"가 있습니다. 나는 WSDL을 해석하는 전문가가 아니다. 나는 실용적인 접근법을 취하고 내 요청을 보낼 때 서버에서 오는 것을 디버깅한다. Savon은 좋은 로깅을 제공합니다. 당신의 환경에서 정확히 동일한 네임 스페이스 접두사를 사용하여 예제를 사용하려고 시도 했습니까? –

+0

당신이 제안한대로 정확히 시도했지만 첫 번째 게시물의 오류 메시지 인 위와 같은 오류 메시지가 표시됩니다 (위 참조). " 'EndElement'의 의미가 없음 ''LogonRequestMsg '네임 스페이스'http : //affilinet.framework.webservices/Svc '에서 예상하지 않습니다.'Username | Password | WebServiceType ''오류 메시지가 나타날 것으로 예상됩니다. 이러한 데이터가 제공되고 나머지 요청은 Savon에 의해 제공된 WSDL에 따라 빌드됩니다. 외관상으로는 Savon는 아무도 따르지 않는 요구를 건설하고있다. – user2148956

1

내가 여러 요청이 네임 스페이스에 다른 순서를 본 후에 문제가, 네임 스페이스 순서로 생각입니다 이상

빠른 더러운 방법으로는 얻을 수 있습니다. 이 코드는 날 (savod 버전 1) 작동

, 네임 스페이스를 덮어 :

message = { 
       'ins0:Username' => 'XXXXXXX', 
       'ins0:Password' => 'XXXXXXX', 
       'ins0:WebServiceType' => 'XXXXXX', 
       :order!  => ['ins0:Username', 'ins0:Password', 'ins0:WebServiceType'] 
      } 


    @client.wsdl.document = 'https://api.affili.net/V2.0/Logon.svc?wsdl' 

    response = @client.request :logon do 
    soap.body = message 
    soap.namespaces["xmlns:ins0"] = "http://affilinet.framework.webservices/types" 
    soap.namespaces["xmlns:ins1"] = "http://schemas.microsoft.com/2003/10/Serialization/Arrays" 
    soap.namespaces["xmlns:ins2"] = "http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation" 
    soap.namespaces["xmlns:ins3"] = "http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF" 
    end