RSS feed
<< SOAP droplet | Home | Bros before hoes >>

SOAP shell script

Yesterday I demonstrated a SOAP request using vbs. Here is a comparable shells script. If you don't have /usr/bin/nc then you can try substituting it with /usr/bin/telnet. I've had trouble with telnet escaping certain characters.

#!/bin/sh
hst=swanandmokashi.com
url=/HomePage/WebServices/QuoteOfTheDay.asmx
act=http://swanandmokashi.com/GetQuote

[ -z "$1" ] && { echo "Specify the file you wish to trasfer." ; exit 0 ; }
[ ! -f "$1" ] && { echo "Cannot open $1." ; exit 0 ; }
{
  echo "POST $url HTTP/1.1" ; \
  echo "Host: $hst" ; \
  echo "Content-Type: text/xml; charset=utf-8" ; \
  echo "Content-Length: `stat -c%s $1`" ; \
  echo "SOAPAction: \"$act\"" ; \
  echo ; \
  cat $1 ; \
  sleep 3 ;
} | \
/usr/bin/nc $hst 80  2>/dev/null | tr -d '\15\32' | \
{
  while [ "`read r; echo $r`" != "" ]; do \
    test ; \
  done ; \
  cat ;
}



Add a comment Send a TrackBack
Home