How to force Savon to use a specific parameter case - ruby

I"m trying to connect to a SOAP API using Savon.
The WSDL shows this:
wsdl:operation name="CustomerList" parameterOrder="Username Password Settings">
<wsdl:input message="impl:CustomerListRequest" name="CustomerListRequest"/>
<wsdl:output message="impl:CustomerListResponse" name="CustomerListResponse"/>
</wsdl:operation>
Customer Support says to use a request such as this:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ei2="http://ei2.nobj.nable.com/">
<soap:Header/>
<soap:Body>
<ei2:customerList>
<!--Optional:-->
<ei2:username>testaccount#n-able.com</ei2:username>
<!--Optional:-->
<ei2:password>!PDf2lfij23l!!</ei2:password>
<!--Zero or more repetitions:-->
<ei2:settings>
<!--Optional:-->
<ei2:key>null</ei2:key>
<!--Optional:-->
<ei2:value>null</ei2:value>
</ei2:settings>
</ei2:customerList>
</soap:Body>
</soap:Envelope>
This is my request:
{"SOAPAction"=>"\"CustomerList\"", "Content-Type"=>"text/xml;charset=UTF-8", "Content-Length"=>"452"}
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="http://www.n-able.com/mickey" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<impl:CustomerList>
<username>test#test.com</username>
<password>MytestPassword1234</password>
<settings>
<listSOs>false</listSOs>
</settings>
</impl:CustomerList>
</env:Body>
</env:Envelope>
The difference is that the WSDL which Savon consumes and generates methods to call off of, is making my request send CustomerList instead of the customerList the API seems to be expecting.
Is there a way to force Savon to send CustomerList instead of customerList without constructing the entire SOAP Request by hand?
Edit 1
Found the answer in this Github Issue. https://github.com/savonrb/savon/issues/530
By adding the following to a gemspec, I was able to get a well formed request:
spec.add_runtime_dependency 'savon', '~> 2.3'
spec.add_runtime_dependency 'wasabi', '~> 3.2'

include one of those when you build your client:
convert_request_keys_to :camelcase # or one of [:lower_camelcase, :upcase, :none]
or work without the WSDL and hand code the call with 'strings'.

Related

i want to test OSB flow via its proxy service url in browser. With its URI it gives error and using postman also gives error

i installed postman utility in my Google chrome browser and i put proxy URl in postman utility address bar after selecting http post method. URL is http://localhost:7021/Testing2CBR/Proxy/ProxyGateway
and request code is
<loanRequest xmlns:java="java:normal.client">
<!--Optional:-->
<java:Name>maha</java:Name>
<!--Optional:-->
<java:SSN>1234</java:SSN>
<!--Optional:-->
<java:Rate>1</java:Rate>
<!--Optional:-->
<java:Amount>10</java:Amount>
<!--Optional:-->
<java:NumOfYear>3</java:NumOfYear>
<!--Optional:-->
<java:Notes>123</java:Notes>
<loanRequest>
but it gives me error
<faultstring>BEA-382030: Failure while unmarshalling message: Failed to parse XML text</faultstring>
i modified my request as
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<loanRequest xmlns:java="java:normal.client">
<!--Optional:-->
<java:Name>maha</java:Name>
<!--Optional:-->
<java:SSN>1234</java:SSN>
<!--Optional:-->
<java:Rate>1</java:Rate>
<!--Optional:-->
<java:Amount>10</java:Amount>
<!--Optional:-->
<java:NumOfYear>3</java:NumOfYear>
<!--Optional:-->
<java:Notes>123</java:Notes>
<loanRequest>
</soapenv:Body>
</soapenv:Envelope>
and i also tried adding header over the request message, as mentioned in OSB proxy console window
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
but i am still getting the error. How should i format my xml request message so that Proxy service url accepts it in my postman utility of google chrome browser with http post method?
Test the proxy using the debug option in /sbconsole . You can enter the request, or you can choose enter the entire soap envelope. The pre-filled values in the text area can be used to create your own message.

Ruby Savon: Call SOAP webservice without operation

I need to call a SOAP service that doesn’t contain any operation encapsulation on the body.
Normally with Savon (Ruby 2.3, Savon 2.11) we have:
client = Savon.client(endpoint: 'http://example.com', namespace: 'http://v1.example.com')
response = client.call(:opName, message_hash)
And this will generate a request like:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://v1.example.com" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<wsdl:opName>
...message content ...
</wsdl:opName>
</env:Body>
</env:Envelope>
But I dont want it to generate the <wsdl:opName> node. I tried to passnil as the operation but it generates the tag as <wsdl:>.
I want to generate a SOAP request without it, like:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://v1.example.com" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
...message content ...
</env:Body>
</env:Envelope>

How send Soap custom message using ruby savon client

I need send message request in Ruby.This message works in the SoapUI see example below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body><auth:callAuth xmlns:auth="http://auth.org"><auth:StringInput><?xml version="1.0" encoding="UTF-8" ?><ns0:TestService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://xml.netbeans.org/schema/TestService" xsi:schemaLocation="http://xml.netbeans.org/schema/TestService AuthReqType.xsd http://xml.netbeans.org/schema/TestService HeaderType.xsd http://xml.netbeans.org/schema/TestService AuthResType.xsd http://xml.netbeans.org/schema/TestService TestService.xsd"><ns0:Header><ns0:Version>3.4.2</ns0:Version><ns0:SrcApp>Test</ns0:SrcApp><ns0:TargetApp>AppName</ns0:TargetApp><ns0:SrcMsgId>00000001198469411500</ns0:SrcMsgId><ns0:TranTimeStamp>20130329104502</ns0:TranTimeStamp></ns0:Header><ns0:Body><ns0:AuthReq><ns0:MsgType>0200</ns0:MsgType><ns0:RvslCde>00</ns0:RvslCde></ns0:AuthReq></ns0:Body></ns0:TestService> ]]></auth:StringInput></auth:callAuth></soapenv:Body>

Savon ruby gem adds ins0 to tags

Using the savon gem, I get the following request XML:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="URL"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ins0="SOME URL">
<soap:Body>
<ins0:Test xmlns="SOME URL">
</ins0:Test>
</soap:Body>
</soap:Envelope>
But it needs to be this instead:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="URL"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Test xmlns="SOME URL">
</Test>
</soap:Body>
</soap:Envelope>
Notice ins0 was removed.
Any suggestions?
The two XML documents are equivalent, so there should be no issues as long as the document is parsed by an XML compliant agent.
The Savon generated document is simply creating a namespace prefix of ins0 for the "SOME URL" namespace. This is convenient for a large SOAP document with many elements from that namespace. In this example, the prefix is not really necessary.
The only potential issue I can see is that the Savion generated document seems to declare the ins0 namespace twice - once in the soap:Envelope and then again in the soap:Body. Seems superfluous and potentially open to error.

CleverElements / Sendcockpit SOAP API parameters aren't recognized

I'm trying to use the CleverElements SOAP API, but I can't get it to work. I have honestly never worked with SOAP (but a lot with XML-RPC, REST, etc.), and thought it should be straightforward.
I'm using Ruby with the savon gem. I can call any function via SOAP which doesn't need any parameters, but on functions with parameters, the SOAP service doesn't recognize the parameters.
This is my request:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="Sendcockpit/API" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="Sendcockpit/API">
<env:Header>
<validate>
<userid>32027</userid>
<apikey>**************</apikey>
<version>1.0</version>
<mode>live</mode>
</validate>
</env:Header>
<env:Body>
<apiGetListDetails>
<listID>72472</listID>
</apiGetListDetails>
</env:Body>
</env:Envelope>
This is the WSDL file: http://api.sendcockpit.com/server.php?wsdl
Am I missing something (maybe dead simple, super obvious, basic SOAP) stuff?
Never mind. Apparently I need a wrapping <ctListRequest> node. I was under the impression that savon applies all things specified by the wsdl file...
This request works:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="Sendcockpit/API" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="Sendcockpit/API">
<env:Header>
<validate>
<userid>32027</userid>
<apikey>***********</apikey>
<version>1.0</version>
<mode>live</mode>
</validate>
</env:Header>
<env:Body>
<apiGetListDetails>
<ctListRequest>
<listID>72472</listID>
</ctListRequest>
</apiGetListDetails>
</env:Body>
</env:Envelope>

Resources