|
NAMEProtocol::XMLRPC::Client - Simple XML-RPC client SYNOPSIS my $xmlrpc = Protocol::XMLRPC::Client->new(
http_req_cb => sub {
...
$cb->(..);
}
);
$xmlrpc->call(
'http://example.com/xmlrpc' => 'plus' => [1, 2] => sub {
my ($self, $method_response) = @_;
print $method_response->param->value, "\n";
},
sub {
print "internal error\n";
}
);
DESCRIPTIONProtocol::XMLRPC::Client is a simple XML-RPC client. You provide callback subroutine for posting method requests. LWP, AnyEvent::HTTP etc can be used for this purpose. ATTRIBUTES"http_req_cb" my $xmlrpc = Protocol::XMLRPC::Client->new(
http_req_cb => sub {
my ($self, $url, $method, $headers, $body, $cb) = @_;
...
$cb->($self, $status, $headers, $body);
A callback for sending request to the xmlrpc server. Don't forget that User-Agent and Host headers are required by XML-RPC specification. Default values are provided, but you are advised to change them. Request callback is called with:
Response callback must be called with:
METHODS"new" my $xmlrpc = Protocol::XMLRPC::Client->new(http_req_cb => sub { ... });
Creates Protocol::XMLRPC instance. Argument http_req_cb is required. "call" $xmlrpc->call(
'http://example.com/xmlrpc' => 'plus' => [1, 2] => sub {
my ($self, $method_response) = @_;
...
}
);
Creates Protocol::XMLRPC::MethodCall object with provided parameters and calls http_req_cb with url and body. Upon response parses and created Protocol::XMLRPC::MethodResponse object and calls provided callback. Parameter are optional. But must be provided as an array reference. Parameters types are guessed (more about that in Protocol::XMLRPC::ValueFactory).
|