views:

247

answers:

2

I am new to Ruby. I am having trouble passing the parameters to a web method.

factory = SOAP::WSDLDriverFactory.new('https://api.affili.net/V2.0/Logon.svc?wsdl')
driver = factory.create_rpc_driver

driver.Logon(...)

How can I pass in the required parameters? I have tried passing in an array, but the paramters are made nil, I tried creating a class for the paramters .. but the same problems occur.

The WSDL for the log on is

<xsd:complexType name="Logon">
     <xsd:sequence>
     <xsd:element minOccurs="0" name="Username" nillable="true" type="xsd:string"/>
     <xsd:element minOccurs="0" name="Password" nillable="true" type="xsd:string"/>
     <xsd:element name="WebServiceType" type="tns:WebServiceTypes"/>
     <xsd:element minOccurs="0" name="DeveloperSettings" nillable="true"          type="tns:TokenDeveloperDetails"/>
  <xsd:element minOccurs="0" name="ApplicationSettings" nillable="true" type="tns:TokenApplicationDetails"/>
</xsd:sequence>
</xsd:complexType>
  <xsd:element name="Logon" nillable="true" type="tns:Logon"/>

How can I pass the params to the Logon method?

Thank you

+2  A: 

Pass parameters as Hash to the Logon method

factory = SOAP::WSDLDriverFactory.new('https://api.affili.net/V2.0/Logon.svc?wsdl')
driver = factory.create_rpc_driver

parameters = {
                'Username' => 'your-username',
                'Password' => 'your-password',
                'WebServiceType' => 'your-webservicetype',
                'DeveloperSettings' => 'your-settings',
                'ApplicationSettings' => 'your-appsettings'
              }

driver.Logon(parameters)

Good luck !

YetAnotherCoder
A: 

Thanks,

It seems to pass the parameters but I it still errors that

unknown namespace qualifier: xml

The error is found in the ns.rb file, and if I print out the name of the element that is unknown .. it tells me: xml:lang

I am still having trouble with this

thanks for helping

Probably your not passing proper values to the parameters like WebServiceType,DeveloperSettings and Applications and also you need to implement another two methods TokenDeveloperDetails TokenApplicationDetails in order to get the CredentialToken as the return type .. Can you post the results of driver.inspect here
YetAnotherCoder
It works no. Thanks .. it was a problem related to soap4r.. it used the code from the ruby api instead of the gem.