i want to make soap calls to web services and I found some objective C code that I translated to applescriptObjc.
I found a service that I could use to test the application (http://www.ripedevelopment.com/webservices/ZipCode.asmx)
I have a text field to input the city name and a button to trigger fetchResults_(sender)
The problem is that the following error occurs :
*** WSMethodInvocationCreate: unable to set argument 0 - the type {__CFURL=} is not supported.
The class of argument 0 is an NSURL so I don’t understand the error message.
Every help is welcome.
script testSoapAppDelegate
property parent : class "NSObject"
property cityName : "New York" -- bound value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
on fetchResults_(sender)
set cityNameStr to current application's NSString's stringWithString_(my cityName as string)
set soapURL to current application's NSURL's URLWithString_("http://www.ripedevelopment.com/webservices/ZipCode.asmx")
log soapURL
set methodName to current application's NSString's stringWithString_("CityToZipCode")
log methodName
set nameSpace to current application's NSString's stringWithString_("http://www.ripedev.com/")
log nameSpace
set params to current application's NSDictionary's dictionaryWithObject_forKey_(cityNameStr, "City")
log params
set paramOrder to current application's NSArray's arrayWithObject_("City")
log paramOrder
set reqHeaders to current application's NSDictionary's dictionaryWithObject_forKey_("http://www.ripedev.com/CityToZipCode", "Soapaction")
log reqHeaders
set soapRequest to createSOAPRequest_({soapURL, methodName, nameSpace, params, paramOrder, reqHeaders})
if soapRequest is not missing value then
set theresult to current application's WSMethodInvocationInvoke(soapRequest)
log "result = " & theresult
if ((current application's WSMethodResultIsFault(theresult)) as boolean) then
log "result = " & theresult's objectForKey_(current application's kWSFaultString)
else
--
end if
else
log "ERROR in createSOAPRequest_"
end if
end fetchResults_
on createSOAPRequest_({soapURL, methodName, nameSpace, params, paramOrder, reqHeaders})
log "=======================createSOAPRequest_========================="
try
set soapReq to current application's WSMethodInvocationCreate(soapURL, methodName, current application's kWSSOAP2001Protocol)
-- set SOAP params
current application's WSMethodInvocationSetParameters(soapReq, params, paramOrder)
-- set method namespace
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSSOAPMethodNamespaceURI, nameSpace)
-- Add HTTP headers (with SOAPAction header)
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSHTTPExtraHeaders, reqHeaders)
-- for good measure, make the request follow redirects.
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSHTTPFollowsRedirects, current application's kCFBooleanTrue)
-- set debug props
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSDebugIncomingBody, current application's kCFBooleanFalse)
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSDebugIncomingHeaders, current application's kCFBooleanFalse)
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSDebugOutgoingBody, current application's kCFBooleanFalse)
current application's WSMethodInvocationSetProperty(soapReq, current application's kWSDebugOutgoingHeaders, current application's kCFBooleanFalse)
return soapReq
on error errmsg
log "createSOAPRequest " & errmsg
return missing value
end try
end createSOAPRequest_
end script
Model: MacBook Pro
AppleScript: Xcode 4.2.1 Build 4D502
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)