Java Reference
In-Depth Information
LISTING 20.2
Continued
16: </value>
17: </param>
18: </params>
19: </methodResponse>
In Listing 20.2, lines 1-8 are the HTTP headers, and lines 10-19 are the XML-RPC
response. You can learn the following things from this listing:
The response is 157 bytes in size and in XML format (lines 6 and 8).
n
The value returned by the remote method is an integer that equals 169 (line 15).
n
An XML-RPC response contains only one argument, contrary to what you might expect
from the params tag in line 12. If the remote method does not return a value—for exam-
ple, it might be a Java method that returns void —an XML-RPC server still returns some-
thing.
This return value can be primitive data, strings, arrays of varying dimensions, and more
sophisticated data structures such as key-value pairs (the kind of thing you would imple-
ment in Java using HashMap or one of its subclasses).
The XML-RPC request and response examples were generated by
a server run by the Advogato open source advocacy site. You can
find out more about its XML-RPC server at the web address
http://www.advogato.org/xmlrpc.html.
Several XML-RPC debuggers on the web can be used to call
remote methods and see the full XML-RPC request and response,
which makes it much easier to determine if a client or server is
working correctly. One's available at the web page http://gggeek.
raprap.it/debugger.
NOTE
Choosing an XML-RPC Implementation
Although you can work with XML-RPC by creating your own classes to read and write
XML and exchange data over the Internet, an easier route is to use a preexisting Java
class library that supports XML-RPC.
 
 
Search WWH ::




Custom Search