NAME

Frontier::RPC2 - encode/decode RPC2 format XML

SYNOPSIS

use Frontier::RPC2;

$coder = Frontier::RPC2->new;

$xml_string = $coder->encode_call($method, @args);
$xml_string = $coder->encode_response($result);
$xml_string = $coder->encode_fault($code, $message);

$call = $coder->decode($xml_string);

$response_xml = $coder->serve($request_xml, $methods);

$boolean_object = $coder->boolean($boolean);
$date_time_object = $coder->date_time($date_time);
$base64_object = $coder->base64($base64);

DESCRIPTION

Frontier::RPC2 encodes and decodes XML RPC calls.

$coder = Frontier::RPC2->new()

Create a new encoder/decoder.

$xml_string = $coder->encode_call($method, @args)

`encode_call' converts a method name and it's arguments into an RPC2 `methodCall' element, returning the XML fragment.

$xml_string = $coder->encode_response($result)

`encode_response' converts the return value of a procedure into an RPC2 `methodResponse' element containing the result, returning the XML fragment.

$xml_string = $coder->encode_fault($code, $message)

`encode_fault' converts a fault code and message into an RPC2 `methodResponse' element containing a `fault' element, returning the XML fragment.

$call = $coder->decode($xml_string)

`decode' converts an XML string containing an RPC2 `methodCall' or `methodResponse' element into a hash containing three members, `type', `value', and `method_name'. `type' is one of `call', `response', or `fault'. `value' is array containing the parameters or result of the RPC. For a `call' type, `value' contains call's parameters and `method_name' contains the method being called. For a `response' type, the `value' array contains call's result. For a `fault' type, the `value' array contains a hash with the two members `faultCode' and `faultMessage'.

$response_xml = $coder->serve($request_xml, $methods)

`serve' decodes `$request_xml', looks up the called method name in the `$methods' hash and calls it, and then encodes and returns the response as XML.

$boolean_object = $coder->boolean($boolean); =item $date_time_object = $coder->date_time($date_time); =item $base64_object = $coder->base64($base64);

These methods create and return XML-RPC-specific datatypes that can be passed to the encoder. The decoder may also return these datatypes. The corresponding package names (for use with `ref()', for example) are `Frontier::RPC2::Boolean', `Frontier::RPC2::DateTime::ISO8601', and `Frontier::RPC2::Base64'.

You can retrieve the value of boolean, date/time, and base64 data using the `value' method of those objects, i.e.:

$boolean = $boolean_object->value;

SEE ALSO

perl(1), Frontier::Daemon(3), Frontier::Client(3)

<http://www.scripting.com/frontier5/xml/code/rpc.html>

AUTHOR

Ken MacLeod <ken@bitsko.slc.ut.us>