osx - How can I make AppleScript SOAP work with existing SOAP webservices (e.g. W3Schools' CelsiusToFarenheit example)? -
i'm using applescript editor. run following code there:
tell application "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl" call soap {method name:"celsiustofahrenheit", method namespace uri:"http://www.w3schools.com/webservices/", parameters:{celsius:50 string}, soapaction:"http://www.w3schools.com/webservices/celsiustofahrenheit"} end tell
if execute above code, "error" string (which not expected). generated request follows:
<?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:celsiustofahrenheit xmlns:m="http://www.w3schools.com/webservices/"> <celsius xsi:type="xsd:int">50</celsius> </m:celsiustofahrenheit> </soap-env:body> </soap-env:envelope>
if edit request (i used fiddler edit request):
<?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> <celsiustofahrenheit xmlns="http://www.w3schools.com/webservices/"> <celsius xsi:type="xsd:int">50</celsius> </celsiustofahrenheit> </soap-env:body> </soap-env:envelope>
- change "m:celsiustofarenheit" "celsiustofarenheit"
- change "xmlns:m" "xmlns"
i receive "122" correct response.
my questions are:
- why happening? soap format used "call soap" function old format?
- is there way fix (e.g. remove ":m" or "m:" in request or use different soap format through code setting parameter in "call soap" method [i don't know if possible])?
the skinny:
a bug in
call soap
feature neglects namespace-tag parameters given call properly: method name element prefixedm:
, parameter elements not.the workaround explicitly prefix parameter names
m:
; in above example, use|m:celsius|
instead ofcelsius
- note enclosing|
signs needed can use name otherwise break parsing.
caveat: there chance workaround break should apple ever fix bug.
applying workaround above example gives us:
tell application "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl" call soap {method name:"celsiustofahrenheit", ¬ method namespace uri:"http://www.w3schools.com/webservices/", ¬ parameters:{|m:celsius|:50 string}, ¬ soapaction:"http://www.w3schools.com/webservices/celsiustofahrenheit"} end tell
background:
- (...) soap format used "call soap" function old format?
the short of it: applescript uses soap 1.1 schema, , while apis under hood support soap 1.2, cannot select applescript ((you can from c using carbon))
as described above, soap xml construction has bug, reason call didn't work. (the web service @ http://www.w3schools.com/webservices/tempconvert.asmx support 1.1, alongside 1.2).
here clues regarding importance , maintenance status of call soap
, call xml-rpc
features:
the features described in documentation separate applescript language guide, though appear part of language (could not find them in external dictionaries)
the documentation written in 2001 (as of osx 10.1; , has seen tiny revision in 2005; warning of potentially outdate web-service url added :)).
'2. there way fix (e.g. remove ":m" or "m:" in request or use different soap format through code setting parameter in "call soap" method?
(see workaround above.)
based on documentation-status clues, not hold breath updates or fixes apple - pity, because these features handy.
Comments
Post a Comment