Empty strings in XML-RPC struct replies
Empty strings in XML-RPC struct replies
- Subject: Empty strings in XML-RPC struct replies
- From: Jeff Jungblut <email@hidden>
- Date: Fri, 16 Oct 2009 20:49:35 -0700
- Thread-topic: Empty strings in XML-RPC struct replies
Title: Empty strings in XML-RPC struct replies
I'm using XML-RPC to talk to a PHP script running on a web server. I'm having a problem when the script returns a struct (as opposed to an array or string) -- empty strings in the reply are not properly turned into emtpy strings in the AppleScript record. Example:
property params : {}
tell application "http://cleverdev.net/xmlrpctest.php"
set theData to call xmlrpc {method name:"rpcTest.getStruct", parameters:params}
end tell
get (theData's empty)
--> application "http://cleverdev.net/xmlrpctest.php"
Sniffing the network traffic, this is the XML returned from the PHP script:
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member><name>height</name><value><string>six feet</string></value></member>
<member><name>weight</name><value><string>165</string></value></member>
<member><name>empty</name><value><string></string></value></member>
<member><name>age</name><value><int>43</int></value></member>
</struct>
</value>
</param>
</params>
</methodResponse>
Note that the property “empty” is an empty string. However, the result is instead application "http://cleverdev.net/xmlrpctest.php", and the class of that value is capp.
Empty strings are handled correctly when the XML reply is a single string value, or an array of values. But if the reply is a record, the property values that should be empty strings are instead the target of the XMLRPC call.
Is this a bug?? Is there a workaround? Or is the XMLRPC library I’m using on the PHP side broken?
Before anyone says it must be the PHP side that’s broken, here’s another example using an array result.
property params : {}
tell application "http://cleverdev.net/xmlrpctest.php"
set theData to call xmlrpc {method name:"rpcTest.getArray", parameters:params}
end tell
get (item 3 of theData)
--> ""
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<array><data>
<value><string>one</string></value>
<value><string>two</string></value>
<value><string></string></value>
<value><string>four</string></value>
</data></array>
</value>
</param>
</params>
</methodResponse>
Note the third value in the array is an empty string, and when checking the value in Script Debugger, it was correctly interpreted by AppleScript as an empty string instead of the target application.
Anyone have any ideas how to work around the problem? Help!
--
Jeff Jungblut
email@hidden
Senior Graphic Designer & Web Developer
Uptown Publications
_______________________________________________
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