Florent Bayle

sarcelle.net

1 note

Call SOAP web services using wget

When testing web services, it can be useful to quickly replay a request, or to use cron to check if a web service is up and running. You can use wget for that purpose.

Here is how :

  • Create a file containing your SOAP request. Here is the request to call the Flickr echo web service. Put that code in a file named request.xml :
<s:Envelope
    xmlns:s="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
    <s:Body>
            <x:FlickrRequest xmlns:x="urn:flickr">
                    <method>flickr.test.echo</method>
                    <name>value</name>
            </x:FlickrRequest>
    </s:Body>
</s:Envelope>
  • Call wget with the correct content type, and specify your file as the content of the POST :

    wget http://api.flickr.com/services/soap/ —post-file=request.xml —header=”Content-Type: text/xml” -O response.xml

This will save the result as a file named response.xml.

Filed under tech