RPC::XML::Client - An XML-RPC client class
require RPC::XML; require RPC::XML::Client;
$cli = RPC::XML::Client->new('http://www.localhost.net/RPCSERV'); $resp = $cli->send_request('system.listMethods');
print (ref $resp) ? join(', ', @{$resp->value}) : "Error: $resp";
This is an XML-RPC client built upon the RPC::XML data classes, and using LWP::UserAgent and HTTP::Request for the communication layer. This client supports the full XML-RPC specification.
The following methods are available:
URI
argument may be a
string or an object from the URI class from CPAN.
Any additional arguments are treated as key-value pairs. Most are attached to
the object itself without change. The following are recognized by new
and
treated specially:
See the section on the effects of callbacks on return values, below.
URI
class object is passed as an argument, then
the URI is set to the new value. In either case, the pre-existing value is
returned.
send_request
)
that returns Perl-level data rather than an object reference. The arguments may
be the same as one would pass to the RPC::XML::request constructor, or there
may be a single request object as an argument. The return value will be a
native Perl value. If the return value is undef
, an error has occurred and
simple_request
has placed the error message in the global variable
$RPC::XML::ERROR
.
RPC::XML::fault
value rather than an error string.
If the return value from send_request
is not a reference, then it can only
mean an error on the client-side (a local problem with the arguments and/or
syntax, or a transport problem). All data-type classes now support a method
called is_fault
that may be easily used to determine if the ``successful''
return value is actually a RPC::XML::fault
without the need to use
UNIVERSAL::ISA
.
$realm
is
identical at both locations).
The RPC::XML::Server class supports compression of requests and responses via the Compress::Zlib module available from CPAN. Accordingly, this class also supports compression. The methods used for communicating compression support should be compatible with the server and client classes from the XMLRPC::Lite class that is a part of the SOAP::Lite package (also available from CPAN).
Compression support is enabled (or not) behind the scenes; if the Perl installation has Compress::Zlib, then RPC::XML::Client can deal with compressed responses. However, since outgoing messages are sent before a client generally has the chance to see if a server supports compression, these are not compressed by default.
compress_responses(BOOL)
compress_thresh([MIN_LIMIT])
If a callback is installed for errors or faults, it will be called before
either of send_request
or simple_request
return. If the callback calls
die or otherwise interrupts execution, then there is no need to worry about
the effect on return values. Otherwise, the return value of the callback
becomes the return value of the original method (send_request
or
simple_request
). Thus, all callbacks are expected, if they return at all,
to return exactly one value. It is recommended that any callback return values
conform to the expected return values. That is, an error callback would
return a string, a fault callback would return the fault object.
All methods return some type of reference on success, or an error string on
failure. Non-reference return values should always be interpreted as errors,
except in the case of simple_request
.
This began as a reference implementation in which clarity of process and readability of the code took precedence over general efficiency. It is now being maintained as production code, but may still have parts that could be written more efficiently.
The XML-RPC standard is Copyright (c) 1998-2001, UserLand Software, Inc. See <http://www.xmlrpc.com> for more information about the XML-RPC specification.
This module is licensed under the terms of the Artistic License that covers Perl. See <http://language.perl.com/misc/Artistic.html> for the license itself.
the RPC::XML manpage, the RPC::XML::Server manpage
Randy J. Ray <rjray@blackperl.com>