POE::Filter::XML::RPC::Request - An abstracted XMLRPC request
use 5.010; use POE::Filter::XML::RPC::Request; use POE::Filter::XML::RPC::Value; my $request = POE::Filter::XML::RPC::Request->new ( 'SomeRemoteMethod', [ POE::Filter::XML::RPC::Value->new('Some Argument') ] ); say $request->method_name(); # SomeRemoteMethod say $request->get_parameter(1)->value(); # Some Argument
POE::Filter::XML::RPC::Request provides and abstracted XMLRPC request object to use when constructing requests to a remote server.
new() accepts two arguments, one, the method name to be used, and two, an array reference of POE::Filter::XML::RPC::Value objects that are the positional arguments to the method in question.
method_name() returns the current method name of the request. Can also take an argument that will change the method name to the provided argument.
parameters() returns an array reference of all of the Values currently stored in the request in the order they were provided. This is a zero based array.
get_parameter() takes a one based index into the positional parameters of the request. Returns the Value object at that position.
insert_parameter() takes two arguments, one, the Value object to be inserted and two, the one based index to which the Value should be associated.
delete_parameter() takes a one based index into the positional parameters of the request. Returns the deleted Value.
add_parameter() takes a Value object as its sole argument and appends it to the end of the parameters of the request.
Request is actually a subclass of POE::Filter::XML::Node and so all of its methods, including XML::LibXML::Element's, are available for use. This could ultimately be useful to avoid marshalling all of the data out of the Node and instead apply an XPATH expression to target specifically what is desired deep within a nested structure.
The reason the parameter methods are one based indexed is because of how XPATH works and what the spec calls out for when it comes to the position() predicate.
Copyright 2009 Nicholas Perez. Licensed and distributed under the GPL.