prakashpoudel
prakashpoudel

Reputation: 577

Access SOAP webservice via Command Line in Ubuntu

I have a SOAP webservices. I can call services from the application itself. But now I have requirement such that it can be called internally for the server itself.

In other word I need a way to call this service from Linux command line. I heard curl command can do it. But I am not sure what are the things I need to take care for curl to work/

ID: 1
Address: http://localhost:9000/sampleApp/hellome
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:sayHelloWithTime xmlns:ns1="http://hello.sample.com"><ns1:timeOfDay>2015-02-05T00:00:00-05:00</ns1:timeOfDay></ns1:sayHelloWithTime></soap:Body></soap:Envelope>

I am not sure what curl command will allow to call this webservice.

Upvotes: 1

Views: 6077

Answers (1)

Chathuranga Tennakoon
Chathuranga Tennakoon

Reputation: 2189

you can use the following command to invoke the web service from linux terminal.

curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @your_soap_request.xml -X POST http://localhost:9000/sampleApp/hellome

your_soap_request.xml will be used to define the soap request message with required parameters. change the values accordingly.

your_soap_request.xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="XXXXCHANGEXXXXXX">
   <soapenv:Header/>
   <soapenv:Body>
      <impl:methodName>
         <arg0>XXXXXX</arg0>
      </impl:methodName>
   </soapenv:Body>
</soapenv:Envelope>

hope this will be helpful for you. let me know if you have any query

Thanks

Upvotes: 4

Related Questions