∟RPC::XML::Server - XML-RPC Server Interface Class
This section describe the RPC::XML::Server class - the RPC-XML server and programming interface for remote method call handlers.
RPC::XML::Server - A XML-RPC server and programming interface for remote method
handlers. It supports the following methods:
new(host=>'hostName', port=>'port', queue=>'queueSize') -
Constructs and returns a XML-RPC server object that listens on the specified
host name at the specified port with the specified queue size. The following
statement shows you an example of how to use this constructor:
$server = RPC::XML::Server->new(host => 'localhost',
port => '8001', queue='5');
add_method({name=>'methodName', signature=>\@sigList, code=>\&function}) - Adds
a method to the server with a hash to specify the method name, the signature list,
and the actual function that handles the method. The following statement adds
a method called "com.herong.getCelsius" to the server. This method has one signature
of returning 'double' and taking one 'double'.
The method handler is a function called "getCelsius".
Rules on adding methods and dispatching method calls:
A signature is a space delimited data types, with the first one being the
return data type, and the rest being input parameters.
Multiple signatures can be specified when adding a method to allow the
method to be called in multiple ways. For example, if "signature => [ 'double',
'double double' ]" is used, the method can be called with no parameter, or with
one 'double' parameter. Please note that the manual is very unclear about
how signature should be used.
When the server receives a XML-RPC request, it will validate the request
against the specified signatures. The server will not dispatch the call if the
request can not match any signature.
If a XML-RPC request matches a signature, it will dispatch the call to the
specified handler function with all given parameters in the request plus
the server object as the first argument. This is similar to the function call
behavior when using the '->' operator.
When a handler function returns, the server will take returning value and
convert it to the return data type specified in the method signature.
The server will evaluate the handler function returning value in scalar context.
This means that means if the handler function returns a list, the server will
get one value, the number of values in the list.
If the handler functions returns an object (really a reference), the server will take the content
of the object and convert it to the return data type. For example, if the return
data type is 'array', and the handler function is returning a reference to a list,
all elements in the list will be returned as an 'array'.