ruby on rails - Trying to build SOAP Request with Savon? -


i trying hit soap service ruby on rails - soap ui can hit fine , request xml below:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:mun="http://schemas.datacontract.org/2004/07/myexternalservice.map" xmlns:mun1="http://schemas.datacontract.org/2004/07/myexternalservice.common.map">    <soapenv:header/>    <soapenv:body>       <tem:getinformationsforcoordinates>          <!--optional:-->          <tem:coordreq>             <!--optional:-->             <mun:coordinates>                <!--zero or more repetitions:-->                <mun:coordinate>                   <!--optional:-->                   <mun:id>1</mun:id>                   <!--optional:-->                   <mun:qualityindex>90</mun:qualityindex>                   <!--optional:-->                   <mun:x>-110.5322</mun:x>                   <!--optional:-->                   <mun:y>35.2108</mun:y>                </mun:coordinate>             </mun:coordinates>          </tem:coordreq>          <!--optional:-->          <tem:analysistypes>             <!--zero or more repetitions:-->             <mun:analysistype>additional</mun:analysistype>          </tem:analysistypes>       </tem:getinformationsforcoordinates>    </soapenv:body> </soapenv:envelope> 

if copy exact xml ruby string request = %q(xml string) savon , use method , in savon call following:

response = client.call(:get_info, xml: request) 

it works expected , response - in reality want passing parameters savon. far have tried following:

  coordinate = { id: '1', x: -110.5322, y: 35.2108, qualityindex: 90 }   coordinates = {coordinates: [coordinate] }   coordinatereq = {coordreq: {coordinates: coordinates} }   response = client.call(:get_informations_for_coordinates, message: coordinatereq) 

this fails , if @ xml sending below:

<env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">   <env:body>     <tns:getinformationsforcoordinates>       <coordreq>         <coordinates>           <coordinates>             <id>1</id>             <x>-110.5322</x>             <y>35.2108</y>             <qualityindex>90</qualityindex>           </coordinates>         </coordinates>       </coordreq>     </tns:getinformationsforcoordinates>   </env:body> </env:envelope> 

in comparison sent soap ui missing xmlns:mum namespace - there anyway can add request added each parameter i.e. x, y qualityindex - tem similar tns in savon call added coordreq in soapui not in savon call - there anyway can add it?

also having difficulty in working out how build analysistypes , analysistype part of request?

from documentation:

namespaces

if don’t pass namespace savon::client#request, savon register target namespace (“xmlns:wsdl”) you. if did pass namespace, savon use instead of default one. example:

client.request :v1, :get_user  <env:envelope     xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:xsd="http://www.w3.org/2001/xmlschema"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:v1="http://v1.example.com">   <env:body>     <v1:getuser>   </env:body> </env:envelope> 

you can set namespaces or overwrite namespaces set savon. namespaces stored simple hash.

# setting new namespace soap.namespaces["xmlns:g2"] = "http://g2.example.com"  # overwriting "xmlns:wsdl" namespace soap.namespaces["xmlns:wsdl"] = "http://ns.example.com" 

apparently, savon 2, setting multiple namespaces impossible:

i found not possible (for now) set multiple namespaces on version 2 of savon.

for migrate application on savon version 1 , worked =)


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -