Forum OpenACS Development: Re: XML-RPC package ready

8: Re: XML-RPC package ready (response to 4)
Posted by Vinod Kurup on
Hey Andrew,

I did look at the SOAP-Gateway package which seems real nice and should be useful for SOAP. I couldn't, in my brief inspection, figure out how to have it do plain XML-RPC, it only took care of SOAP requests.

I'm not sure if ns_xmlrpc was the best foundation to start with, but it was the quickest. I wanted to use tDOM since we were already using tDOM in OpenACS 5, therefore I didn't look at TclSOAP. I fixed a few bugs here and there and it seems to work well.

But, I didn't do the automatic conversion between Tcl and XML-RPC that you mention. I thought about doing it, but I couldn't figure out a clean way to do it. XML-RPC to Tcl conversion is automatic (which is easy since Tcl doesn't care about datatypes). But Tcl to XML-RPC conversion requires the programmer to specify the datatype that he's returning. i.e. return [list -int 23]. Now in some cases, it would be very easy to figure out the datatype from the value and take care of that little detail ourselves. For example, 23 is an int. But what if you're implementing a method that's supposed to return a string, whose value happens to be 23. Our XML-RPC would look at 23, call it an int and return an int. If the XML-RPC client on the other side is using a strongly-typed language, it would be expecting a string and might fail. A similar problem would be trying to differentiate between XML-RPC arrays and structs. In TCL, these are arrays and lists, respectively. But if your proc returns a list with 4 items, there's no way to tell if I should code that as an XML-RPC array of 4 items or an XML-RPC struct with 2 name-value pairs (or even as an XML-RPC string with four words). We'd have to have a way of procs specifying their signature (with datatypes) somewhere and that seemed harder to implement than having the programmer specify the datatype.