1

提供されているログオン機能を使用して、アフィリネット Web サービスにログオンしようとしています。Rails 3 環境 (3.0.x) で作業しています。私はバージョン 2 で ruby​​ on rails gem Savon を利用し、それは次に SOAP を使用して affilinet に接続します。
最新の wsdl は、https: //api.affili.net/V2.0/Logon.svc?wsdl にあります。
私のコードは次のようになります。

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>  

この要求を Web サービスに送信すると、次の (エラー) 応答が返されます。

<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>

リクエストの違い (Savon と soapUI で生成) が鍵かも!? 特に異なる名前空間: svc/typ と env/tns。何か案は?LogonRequestMsg に svc 名前空間を使用するように Savon に指示するにはどうすればよいですか?

4

2 に答える 2

3

Affili.netのWSDLを調べると、ユーザー名、パスワード、WebserviceTypeなどの名前空間が間違っていることがわかります。

例をもう一度調べた後、名前空間用に編集しました。ユーザー名、パスワード、および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)
于 2013-03-11T14:12:06.380 に答える
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
于 2016-07-19T13:14:58.637 に答える