Friday, June 1, 2012

How to test a webservice from linux command line?

Use cURL

First create the soap request file named soap-request.xml.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetWeather xmlns="http://www.webserviceX.NET">
<CityName>Milan</CityName>
<CountryName>Italy</CountryName>
</GetWeather>
</soap:Body>
</soap:Envelope>
Then use the following curl command to send the request...
curl -H "Content-Type: text/xml; charset=utf-8" \
-H "SOAPAction:http://www.webserviceX.NET/GetWeather" \
-d@soap-request.xml \
http://www.webservicex.net/globalweather.asmx \
> output.xml

Ref:
http://curl.haxx.se/docs/manpage.html
http://josephscott.org/archives/2011/10/timing-details-with-curl/ 

No comments: