Java Reference
In-Depth Information
XML-RPC has been described as the “lowest common denominator” of remote proce-
dure call protocols, but this isn't considered an insult by its originators. Most attempts to
facilitate software communication over a network have been extremely sophisticated,
scaring off developers who have more simple needs.
The XML-RPC protocol can be used to exchange information with any software that
supports HTTP, the
lingua franca
of the Web, and XML, a highly popular, structured for-
mat for data.
By looking at XML-RPC requests and responses, you should be able to figure out how to
use the protocol even without reading the protocol specification.
However, as implementations such as Apache XML-RPC become more extensive, you
can begin using it quickly without ever looking at the protocol at all.
Q When I try to return a
HashMap
object from a remote method, Apache XML-
RPC responds with an
XmlRpcException
that states the object is not sup-
ported. Which objects does it support?
A
Apache XML-RPC returns the following data types: Boolean for
boolean
XML-
RPC values,
byte[]
for
base64
data,
Date
for
dateTime.iso8601
data,
Double
for
double
values,
Integer
for
int
(or i4) values,
String
for
strings
,
Hashtable
for
struct
values, or
Vector
for arrays.
Q I'm writing an XML-RPC client to call a method that returns binary data
(base64, in other words). The
execute()
method of
XmlRpcClient
returns an
object instead of an array of bytes. How do I convert this?
A
Arrays are objects in Java, so casting can be used to convert the object returned by
execute()
to an array of bytes (assuming the object really is an array). The follow-
ing statement accomplishes this on an object named
fromServer
that contains a
byte array:
byte[] data = (byte[]) fromServer;
20