Stuck at converting xml request to corresponding Savon request

68 views
Skip to first unread message

Jatin Dhankhar

unread,
Oct 7, 2016, 7:14:22 AM10/7/16
to Savon
Hi,
I am trying to communicate with a 3-rd party API. I tried both savon and Soap UI but both failed, then I asked them and they gave me equivalent that works. Confused, I toggled the logger and got following XML request which is quite different from what Savon is sending.
Here is the PHP code (I guess that's not needed, but still)
$apiauth =array('UserName'=>'XXXXXX','Password'=>'XXXXXXX','ClientCode'=>'1234')      /
  $wsdl
= 'http://stagewebapi.mylescars.com/service.asmx?wsdl';


     
        $soap
= new SoapClient($wsdl);
        $header
= new SoapHeader('http://tempuri.org/', 'AuthHeader', $apiauth);
        $soap
->__setSoapHeaders($header);            
        $data
= $soap->fetchCities($header);
           
        print_r
($data);


Here is the XML request that PHP is sending and which is working just fine

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Header><ns1:AuthHeader><ns1:UserName>XXXXXXX</ns1:UserName><ns1:Password>XXXXXXX</ns1:Password><ns1:ClientCode>1234</ns1:ClientCode></ns1:AuthHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:fetchCities/></SOAP-ENV:Body></SOAP-ENV:Envelope>




Here is my ruby code so far

require 'savon'

auth_header = { 'UserName'=>'XXXXXXX','Password'=>'XXXXXXXX','ClientCode'=>'1234'}
client = Savon.client(:wsdl  => "http://stagewebapi.mylescars.com/service.asmx?wsdl",
        :namespace_identifier => :ns1 ,:namespace => "http://tempuri.org/" , :log => true, :soap_header => auth_header,
                     :pretty_print_xml => true, :env_namespace => 'SOAP-ENV')


puts client.call(:fetch_cities)



Here is what Savon is producing

<?xml version="1.0" encoding="UTF-8"?>
  <soap-env:Header>
    <UserName>XXXXXXXXXXXXXXX</UserName>
    <Password>XXXXXXXXXXXXX</Password>
    <ClientCode>2873</ClientCode>
  </soap-env:Header>
  <soap-env:Body>
    <ns1:fetchCities/>
  </soap-env:Body>
</soap-env:Envelope>


I don't know how to make it equivalent to the PHP one. Am I missing something.


Thanks 

Reply all
Reply to author
Forward
0 new messages