Re: XML-RPC structs and case-sensitivity
Re: XML-RPC structs and case-sensitivity
- Subject: Re: XML-RPC structs and case-sensitivity
- From: "John W. Baxter" <email@hidden>
- Date: Wed, 21 Jul 2004 13:22:11 -0700
On 7/21/2004 12:31, "Matt Deatherage" <email@hidden> wrote:
>
For some reason, my battles with case-sensitivity and AppleScript continue.
>
:(
>
>
I need to call an XML-RPC method on a remote server with a single parameter of
>
a <struct> that looks like this:
>
>
> <struct>
>
> <member>
>
> <name>Param1</name>
>
> <value><i4>56</i4></value>
>
> </member>
>
> <member>
>
> <name>Param2A</name>
>
> <value><string>my string here</string></value>
>
> </member>
>
> <member>
>
> <name>Param3b</name>
>
> <value><boolean>1</boolean></name>
>
> </member>
>
> </struct>
>
>
The way to do this in AppleScript is with a record:
>
>
> set myStruct to {Param1:56, Param2A:"my string here", Param3b:true}
>
>
Since this struct is the only parameter to the XML-RPC routine, I can call it
>
fairly easily:
>
>
> tell application "http://www.example.com/RPC2"
>
> return call xmlrpc {method name:"method.Mine", parameters:myStruct}
>
> end tell
>
>
After a few hours of hair-tearing, I ran an Ethernet sniffer and saw the XML
>
that AppleScript and/or WebServicesCore is emitting:
>
>
> <struct>
>
> <member>
>
> <name>param1</name>
>
> <value><i4>56</i4></value>
>
> </member>
>
> <member>
>
> <name>param2a</name>
>
> <value><string>my string here</string></value>
>
> </member>
>
> <member>
>
> <name>param3b</name>
>
> <value><boolean>1</boolean></name>
>
> </member>
>
> </struct>
>
>
It's subtle, but important: AppleScript or WebServicesCore has lowercased the
>
name of every member of the struct. The XML-RPC spec says nothing about
>
ignoring case, so this particular application (which I cannot modify) is
>
case-sensitive, and fails. I have the member names with the correct case in
>
my record, but AppleScript won't emit them that way. It correctly preserves
>
the case of the method name, but that's a string and I expect that.
>
>
I haven't been able to find anything on the Web or in the list archives about
>
this, though I can't really get the list archives to respond right now (I
>
searched my local copy for the past year or so). Either I'm missing something
>
or there's a major flaw in the XML-RPC implementation because it forces
>
lowercase on XML that's supposed to be case-sensitive.
>
>
(And, just to eliminate the obvious, it still fails if wrapped in a
>
"considering case" block.)
>
>
Any ideas?
Hi, Matt...
Indeed, the forced lower casing is not good (XML is case sensitive by
definition).
I suspect that the obvious solution of
set myStruct to {|Param1|:56, |Param2A|:"my string here", |Param3b|:true}
will end up passing the pipe characters through into the data stream, which
will be at least as bad...probably worse.
You might want to try building the record using Mark Aldritt's new
List and Record Tools ScriptingAddition. However, it's quite possible that
Mark had to follow Apple's rather strange AppleScript letter case handling
stuff.
Hmmm...no, Mark uses the | notation, it would appear. So if the pipes are
bad, Mark's code won't help.
copy {} to x
set y to set user property "Param1" in x to "this is a test"
y
--> {|Param1|:"this is a test"}
Good luck. I'm tempted to say that AppleScript is the wrong language for
what you want to do. I hope someone can show that that isn't the case.
--John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.