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: Jeff Jungblut <email@hidden>
- Date: Sat, 17 Oct 2009 14:45:22 -0700
- Thread-topic: Empty strings in XML-RPC struct replies
Title: Re: Empty strings in XML-RPC struct replies
on 10/17/09 4:39 AM, Axel Luttgens at email@hidden wrote:
>> 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.
>
> 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"?
The property name does not matter; 'empty' is not special. I changed the property name to 'blahblah' and got the same result.
> 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
Thanks, that does work. But my example above was just a simple test case to verify the bug.
For my real application, I'm doing many different XMLRCP calls to get rows from different tables in a MySQL database, where string fields in the returned rows may or not be empty, and checking the value of every field (property) of every returned row and setting it to an empty string if it's a bogus app reference will slow down the app (and would add a considerable amount of code bloat). Not practical.
I’ve started worked around the problem by using the method calls which return lists of records to just copy the data to a table view. The table view correctly shows an empty cell instead of an app reference for any properties which contain empty strings. Then when I need to get the correct values from a given row in the table, I do a second xmlrpc call which fetches a single row as a list of values instead of a record, and then access the values by index instead of property name.
When running inside an ASS app, the console shows this error for every field in every row that contains an empty string:
2009-10-17 14:09:21.250 WebZine[98024:903] A key or value could not be handled while converting an Apple event record to an NSDictionary.
Researching that error directs me to this page, but I don’t speak Japanese so it’s not of much help:
http://ppmweb.lolipop.jp/kaku-10-release/
--
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