PDA

View Full Version : XMLRPC: STRUCT type support?


bgrant
10-27-2004, 02:14 PM
Hello,

What does the XMLRPC STRUCT type map to in LZX and how does one build a param value of it for a remotecall?


I had presumed Object, e.g.:


<xmlrpc...

<remotecall...

<param...

<method name="getValue">

return { foo : "bar", baz : "buh" };

</method>

</param>

... would result in a request containing:

<methocall...
<methodname...
<params...
<param>
<struct>
<member>
<name>foo</name>
<value>bar</value>
</member>
<member>
<name>... etc etc


But, apparently it never gets far enough to build a request and send it (so I can't tell if XMLRPC struct format is being used by LZX, which is the underlying question here); onerror reports the following when I invoke the remotecall:

rpc/rpc.lzx:268: call to undefined method 'sendEvent'


Any ideas or pointers, much appreciated...


TIA,

Benjamin

pablo
10-28-2004, 08:31 AM
Hi Benjamin,

The XML message will look like:


<?xml version="1.0"?>
<methodCall>
<methodName>foobar</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>foo</name>
<value><string>bar</string></value>
</member>
<member>
<name>baz</name>
<value><string>buh</string></value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>


You can verify this by going to lps/components/rpc/library/xmlrpc.js and modifiying the invoke function. Add this right before the __LZloader.request call:


Debug.write('xmlrpc message:', mesg.xml());


The "call to undefined method 'sendEvent'" error indicates that the method doesn't exist for your xmlrpc object. Are you possibly calling it before the xmlrpc object loads? Can you post a sample snippet?

Cheers,
pablo

bgrant
10-28-2004, 10:47 AM
Thanks Pablo. We've cleared up the sendEvent issue -- and thanks for the debugging tip in the lib, that also helps quite a bit.

We're still getting an error -- from LPS -- when hitting the endpoint, but we note that this only appears to be happening with this particular endpoint. The curious thing is, this endpoint otherwise responds cleanly and works fine with other XMLRPC client requests -- just not, apparently, those coming from LPS. So, given that, and that I can't rule out LPS as the source of the error (I'm hoping someone else can, if that's the case), I'm posting a code snippet here, in case anyone has any insight.

For reference, attached is code that throws:

The element type "init" must be terminated by the matching end-tag "</init>".

pablo
10-28-2004, 01:08 PM
Hi Benjamin,

I checked out the response from that endpoint and it's returning the following XML:


<?xml version="1.0" encoding="utf-8" ?>
<methodResponse>
<params>
<param>
<string>
&lt;user id=&quot;36521976863@N01&quot;&gt;
&lt;username&gt;benjamin_&lt;/username&gt;
&lt;/user&gt;
</string>
</param>
</params>
</methodResponse>


I believe this response is invalid. The XML-RPC spec specifies that param nodes should be wrapped with <value> like:


<param>
<value>
<string>xxx</string>
</value>
</param>



The error returned by LPS is actually misleading and I've filed a bug to make the message clearer, but I believe the endpoint should fix the XML response.

pablo

bgrant
10-28-2004, 01:16 PM
Thanks much Pablo, I will bring this to the attention of the api mailing list for the endpoint server...