« We're deterministic | Main | 2006 International Whistlers Competition: Cancelled »

Using curl to post XML to web services

I find myself posting XML documents to REST service endpoints often. I wrote the following little shell script to make things easy.
S=`basename $0`
curl -D - -X POST -H 'Content-type: text/xml' -d @$2 http://$1/$S
I call this script curl-post.sh. Now, all I have to do is symlink curl-post.sh to a more descriptive name (generally the name of the REST service endpoint I'm using). Then I type serviceName hostname/path filename to post data to that endpoint and see the results (incl. headers) on the commandline.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)