Java Reference
In-Depth Information
The following statement creates a client to an XML-RPC client on the host
cadenhead.
org
at the port 4413:
XmlRpcClient client = new XmlRpcClient(“
http://cadenhead.org:4413”
);
If you are calling a remote method with any arguments, they should be stored in a
Vector
object, a data structure that holds objects of different classes.
NOTE
Vectors were covered during Day 8, “Data Structures.” They are
part of the
java.util
package.
To work with vectors, call the
Vector()
constructor with no arguments and call its
addElement(
Object
)
method with each object that should be added to the vector.
Objects can be of any class and must be added to the vector in the order that they are
called in the remote method.
The following data types can be arguments to a remote method:
byte[]
arrays for
base64
data
n
Boolean
objects for
boolean
values
n
Date
objects for
dateTime.iso8601
values
n
Double
objects for
double
values
n
Integer
objects for
int
values
n
String
objects for
string
values
n
Hashtable
objects for
struct
values
n
Vector
objects for arrays
n
The
Date
,
Hashtable
, and
Vector
classes are in the
java.util
package.
20
For example, if an XML-RPC server has a method that takes
String
and
double
argu-
ments, the following code creates a vector that holds each of the arguments:
String code = “conical”;
Double xValue = new Double(175);
Vector parameters = new Vector();
parameters.addElement(code);
parameters.addElement(xValue);