• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
XML-RPC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XML-RPC


  • Subject: XML-RPC
  • From: Takaaki Naganoya <email@hidden>
  • Date: Mon, 05 Oct 2015 00:34:07 +0900

Hi All,

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”.
“XMLRPC.framework” (https://cocoapods.org/pods/xmlrpc) was found. I built and installed it to my OS X 10.11 environment.

The result was…
—> "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

What’s wrong with me?



<AppleScript 1…This works>
tell application "http://yubin.senmon.net/service/xmlrpc/"
call xmlrpc {method name:"yubin.getVersion", parameters:{}}
end tell
</AppleScript 1>

<AppleScript 2>
-- Created 2015-10-04 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "XMLRPC" --https://cocoapods.org/pods/xmlrpc

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

set aRes to my callXMLRPC("http://yubin.senmon.net/service/xmlrpc/", "yubin.getVersion", {})
--> {​​​​​(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:
</AppleScript 2>


--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: XML-RPC
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Scripting the Photos application
  • Next by Date: Re: AppleScript (bug?) in iTunes on El Capitan
  • Previous by thread: Scripting the Photos application
  • Next by thread: Re: XML-RPC
  • Index(es):
    • Date
    • Thread