Friday, November 26, 2010

Web services : cURL

If you need to do some web service client testing, there are a number of tools like SOAPUI but they all involve installing programs etc.

Then I came across this neat tool cURL

To quote from the docs:

"curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks."

It runs on a wide variety of platforms.

So how do you use it to test a web service?

You need to mock-up what the actual SOAP packet looks like e.g.

to test a web service called TestWS, the information might look like:


Save this in a file called TestWS.xml.

The command line for cURL would then be:

curl --data @TestWS.xml --header "Content-Type: text/xml" --header "Accept-Encoding: gzip,deflate" --verbose http://host:port/TestWSService

This then sends the HTTP POST which itself contains a SOAP message which invokes the web service.

The verbose option prints out both the request and the response.


No comments: