Consuming SOAP Services on OSX 1

Posted by markm Thu, 30 Apr 2009 09:40:00 GMT

SOAP is bloated and I hate dealing with it. I still have to do it. When dealing with consuming SOAP services from OS X I like to have a couple of items in my bag of tricks to get up and running: a SOAP Client and a way to do base64 decoding. This way I am able to test the service without writing any code. Too often I beat my head against my keyboard over a piece of code only to realize the service itself is the problem.

Here is the SOAP Client that I use: SOAP Client (what an original name!). It really does the trick, though. Point it at the SOAP service WSDL and you are off to the races. It allows you to pass in arguments and call different services. It does it all and returns the XML requested.

Once you have the XML often you will then need to decode a base64 encoded string. Base64 decoding is a bit trickier. Most of the time you can use openssl to decode on a Unix based platform but for some reason it doesn't seem to work for me. I have had to resort to the following perl script:

  #!/bin/sh
  # decode a Base64 encoded file, as a side effect of
  # openssl base64 handling (but without encryption)
  /usr/bin/perl -MMIME::Base64 -e 'print decode_base64(join("", <>))' < "$1" > "$2"

The script takes two arguments: and input file and an output file. I am not a "perl" kinda guy so the script is mostly stolen and probably can be hugely improved.

If your data is a base64 encoded string of gzipped data the next step is to toss the old ".gz" extension on the file and extract the contents using the OS or using gunzip.

Basic stuff really, but it is a pain to track down so I thought I would toss it all in one place.