Re: Empty strings in XML-RPC struct replies
Re: Empty strings in XML-RPC struct replies
- Subject: Re: Empty strings in XML-RPC struct replies
- From: Axel Luttgens <email@hidden>
- Date: Sat, 17 Oct 2009 12:39:52 +0100
Le 17 oct. 2009 à 04:49, Jeff Jungblut a écrit :
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.
Hello Jeff,
Is this true for any empty string returned in a struct, or only for an
empty string named "empty"?
Could you try with a name such as "somestring" instead of "empty"?
Example:
[...]
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.
Which is thus consistent with the reply I get from here when running
your script, as shown in AppleScript Editor's log:
--> {age:43, weight:"165", empty:current application, height:"six
feet"}
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?
Looks like to be a bug on AppleScript's support for xml-rpc; but this
is just a first impression, and some more investigation could be
needed before reporting it.
As far as a workaround is concerned, this seems to work:
property params : {}
tell application "http://cleverdev.net/xmlrpctest.php"
set theData to call xmlrpc {method name:"rpcTest.getStruct",
parameters:params}
if class of empty of theData is application then
set theEmpty to ""
else
set theEmpty to empty of theData
end if
end tell
HTH,
Axel _______________________________________________
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