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.