Know applescript?

August 2, 2006 Comments Off on Know applescript?

Bloody hell… first SOAP coding I do, and doing it in Applescript for the fun of it.


property SOAP_Endpoint_URL : “http://www.flickr.com/services/soap/”

property SOAP_app : “soap”

property method_name : “FlickrRequest”

property method_namespace_URI : “urn:flickr”

property SOAP_action : “”



set the method_parameters to {api_key:”*******************”, method:”flickr.test.echo”, format:”soap2″, dummy:”whatever”}



copy my SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action) to {call_indicator, call_result}

if the call_indicator is false then

beep

display dialog “An error occurred.” & return & return & call_result buttons {“Cancel”} default button 1

else

display dialog “Result is: ” & call_result buttons {“OK”} default button 1

end if



on SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action)

try

using terms from application “http://www.apple.com/placebo”

tell application SOAP_Endpoint_URL

set this_result to call soap ¬

{method name:method_name ¬

, method namespace uri:method_namespace_URI ¬

, parameters:method_parameters ¬

, SOAPAction:SOAP_action}



end tell

end using terms from

return {true, dummy}

on error error_message number error_number

if the error_number is -916 then ¬

set the error_message to “The script was unable to establish a connection to the Internet.”

return {false, error_message}

end try

end SOAP_call



Apart from the placebo thing, this looks kinda cool and elegant, but as I always do… I copy from something that exists. The example I used only returns one variable. When doing it with the Flickr echo… I get SOAP-envelope back with not only the dummy in it, but also method, format and api_key. So when executing this… the variable dummy is not defined…

And it is when the SOAP request returns one single variable.

Advertisements

Comments are closed.

What’s this?

You are currently reading Know applescript? at plαdys.

meta

%d bloggers like this: