Search code examples
soapsavonnetsuite

savon soap attributes


Am trying to query netsuite api for currencies. The following soap request works for me in SOAP UI client. But i am having a hard time trying to get the same working with ruby's savon gem version 0.9.7.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:messages_2012_2.platform.webservices.netsuite.com" xmlns:urn1="urn:core_2012_2.platform.webservices.netsuite.com">
   <soapenv:Header>
      <urn:passport>
         <urn1:email>[email protected]</urn1:email>
         <urn1:password>xxx</urn1:password>
         <urn1:account>xxx</urn1:account>
      </urn:passport>
   </soapenv:Header>
   <soapenv:Body>
      <urn:getAll>
         <urn:record recordType="currency"/>
      </urn:getAll>
   </soapenv:Body>
</soapenv:Envelope>

Basically i am not able to set the attribute on the urn:record element. The following is not working:

response = client.request :urn, :get_all do
  soap.body = { "urn:record" => { :attributes! => { "recordType" => "currency" } } }
end

Please advise.


Solution

  • As explained on http://savonrb.com the key in the attributes! hash has to match the XML tag. You want to write something like this:

    response = client.request :urn, :get_all do
      soap.body = {'urn:record'=>'',
                   :attributes!=>{'urn:record'=>{'recordType'=>'currency'}}
                  }
    end
    

    Please let us know whether this solves it for you.