Perl Tutorials - Herong's Tutorial Examples - 6.00, by Dr. Herong Yang
RPC::XML Client and Data Classes
This section describes the RPC::XML::Client class, the RPC::XML::request class, and data classes.
RPC::XML also offers the client, request and data classes:
RPC::XML::int - A data class representing the XML-RPC '*.value.int' element. It supports the following methods:
new($value) - Constructs and returns a XML-RPC 'int' object with the specified value.
type() - Returns the data type name as a string.
value() - Returns the value as a string
RPC::XML::$valueType - Other data classes representing other XML-RPC value type elements. All data classes supports the same methods as the RPC::XML::int class. For RPC::XML::array or RPC::XML::struct, method value() will return a reference of array or hash.
RPC::XML::request - A message class representing the XML-RPC 'methodCall' element. It supports the following methods:
new('methodName', param1, param2, ...) - Constructs and returns a XML-RPC request object with the specified method name and parameters. Specified parameters must be objects of RPC::XML data classes. The following statement shows you how to construct a request:
$request = RPC::XML::request->new('com.herong.getCelsius', RPC::XML:double->new('100.0'));
as_string() - Returns the XML string representation of the request.
RPC::XML::Client - A XML-RPC client and programming interface for connecting to the server, sending method calls, and receiving returning values. It supports the following methods:
new('url') - Constructs and returns a XML-RPC client object that connects to a server at the specified URL.
send_request($request) - Sends the specified request to the server, and returns a RPC::XML data object representing the only "param" returned in the XML-RPC response. Here is an example of how to use send_request():
$res = $client->send_request($request);
Table of Contents