Challenge with calling SOAP services via Applescript
Monday, July 14, 2008 at 11:48AM I recently had a need to call a SOAP service via applescript. Google to the rescue and I found several examples on the web. At first it appeared that there was an older technique which used sort of an Applescript to Perl bridge to call the service. Later it seems that there is a "call soap" routine built into the System framework on OS X and callable directly from applescript. This makes for some pretty simple looking applescript. I am struggling with issues however calling web services that where built on .NET frameworks. Something seems to be missing in terms of passing parameters to the web service.
Ok I put a log into the web service to watch what comes accross the wire, there's nothing like sniffing your own code :). The service was expecting this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetRecordERD xmlns="http://bla.bla.bla/DUWSPSERD">
<STRRECORD>string</STRRECORD>
</GetRecordERD>
</soap:Body>
</soap:Envelope>
And applescript was actually sending something like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetRecordERD xmlns:m="http://bla.bla.bla/DUWSPSERD">
<STRRECORD xsi:type="xsd:string">JOB</STRRECORD>
</m:GetRecordERD>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Time for some more research.


Reader Comments (1)
Arrg! I'm having the same problem (and apparently so is this guy: http://lists.apple.com/archives/applescript-studio/2007/Apr/msg00038.html)
Basically, I've found that Applescript support for anything XML is SEVERELY lacking and flawed. The problem is that it's adding a namespace ("m"? what?) to the method parameters and most SOAP servers don't like that. Thankfully Apple at least lets you call command line programs so I guess I'm moving over to that!
Geez, and you'd think after 4 major OS revisions they could have fixed this... guess they're spending all their time on making the new laptop look more sleek or thinner or have fancier drop shadows or something stupid like that.