Apple’s genuine "call xmlrpc" function is an "Achilles heel" for all of scripters. It has low reliability and miserable stability.
So, I’d been searching the way to replace it. And I found the way… “call 3rd party framework from AppleScript”.
—> "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
-- Created 2015-10-04 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property xmlRPCres : false
property xmlRPCbody : false
--Check If this script runs in foreground
if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread (Command-Control-R in Script Editor)." buttons {"Cancel"} as critical
error number -128
end if
--> {(NSString) "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.", "Error"}
on callXMLRPC(paramURL, aMethod, aParamList)
set xmlRPCres to false
set xmlRPCbody to false
set aURL to current application's |NSURL|'s URLWithString:paramURL
set aReq to current application's XMLRPCRequest's alloc()'s initWithURL:aURL
set aManager to current application's XMLRPCConnectionManager's sharedManager()
aReq's setMethod:aMethod withParameter:aParamList
aManager's spawnConnectionWithXMLRPCRequest:aReq delegate:(me)
repeat 6000 times
delay 0.01
if xmlRPCres is not equal to false then exit repeat
end repeat
return {xmlRPCres, xmlRPCbody}
end callXMLRPC
--Error Termination
on request:aRequest didFailWithError:aError
set xmlRPCres to aError's localizedDescription()
set xmlRPCbody to "Error"
end request:didFailWithError:
--Authentication Requested
on request:aRequest didReceiveAuthenticationChallenge:aChallenge
if (aChallenge's previousFailureCount) as integer is not equal to 0 then
set xmlRPCres to "Authentication Error"
end if
end request:didReceiveAuthenticationChallenge:
on request:aRequest canAuthenticateAgainstProtectionSpace:protectionSpace
return false
end request:canAuthenticateAgainstProtectionSpace:
--Normal Termination
on request:aRequest didReceiveResponse:aResponse
if (aResponse as boolean) = false then
set xmlRPCres to aResponse's faultCode()
log {"Fault Code:", aResCode}
set xmlRPCbody to aResponse's faultString()
log {"Fault String:", aResFault}
else
set xmlRPCres to aResponse's object()
set xmlRPCbody to aResponse's body()
end if
end request:didReceiveResponse: