NAME
XML::Compile::RPC::Client - XML-RPC based on unofficial schema
INHERITANCE
XML::Compile::RPC::Client
is a XML::Compile::RPC
is a XML::Compile::Cache
is a XML::Compile::Schema
is a XML::Compile
SYNOPSIS
DESCRIPTION
Client XML-RPC implementation, based on an unofficial XML-RPC schema. The schema used is an extended version from one produced by Elliotte Rusty Harold.
Using the schema with XML::Compile means that the messages are validated. Besides, XML::Compile offers you some tricks: for instance, you can pass a time()
result (seconds since epoc)to a dateTime.iso8601
field, which will automaticallu get formatted into the right format.
In XML-RPC, values which do not explicitly specify their type are interpreted as string. So, you may encounter two notations for the same:
<value><string>Hello, World!</string></value>
<value>Hello, World!</value>
The reader (used to produce the $response
) will translate the second syntax in the first. This simplifies your code.
METHODS
Constructors
XML::Compile::RPC::Client->new(OPTIONS)
Option --Defined in --Default
allow_undeclared XML::Compile::Cache <false>
any_element XML::Compile::Cache 'SKIP_ALL'
autoload_underscore_is '_'
block_namespace XML::Compile::Schema []
destination <required>
hook XML::Compile::Schema undef
hooks XML::Compile::Schema []
http_header []
ignore_unused_tags XML::Compile::Schema <false>
key_rewrite XML::Compile::Schema []
opts_readers XML::Compile::RPC []
opts_rw XML::Compile::RPC []
opts_writers XML::Compile::RPC []
prefixes XML::Compile::Cache <smart>
schema_dirs XML::Compile undef
typemap XML::Compile::Schema {}
user_agent <created internally>
xmlformat 0
. allow_undeclared => BOOLEAN
. any_element => CODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'
. autoload_underscore_is => STRING
When calls are made using the autoload mechanism, then you will encounter problems when the method names contain dashes. So, with this option, you can use underscores which will all be replaced to STRING value specified.
. block_namespace => NAMESPACE|TYPE|HASH|CODE|ARRAY
. destination => URI
The address of the XML-RPC server.
. hook => ARRAY-WITH-HOOKDATA | HOOK
. hooks => ARRAY-OF-HOOK
. http_header => ARRAY|OBJECT
Additional headers for the HTTP request. This is either an ARRAY of key-value pairs, or an HTTP::Headers OBJECT.
. ignore_unused_tags => BOOLEAN|REGEXP
. key_rewrite => HASH|CODE|ARRAY-of-HASH-and-CODE
. opts_readers => ARRAY-OF-PAIRS
. opts_rw => ARRAY-OF-PAIRS
. opts_writers => ARRAY-OF-PAIRS
. prefixes => HASH|ARRAY-of-PAIRS
. schema_dirs => DIRECTORY|ARRAY-OF-DIRECTORIES
. typemap => HASH
. user_agent => OBJECT
You may pass your own LWP::UserAgent object, fully loaded with your own settings. When you do not, one will be created for you.
. xmlformat => 0|1|2
XML::LibXML has three different output formats. Format 0
is the most condense, and 1
is nicely indented. Of course, a zero value is fastest.
Accessors
$obj->addHook(HOOKDATA|HOOK|undef)
$obj->addHooks(HOOK, [HOOK, ...])
$obj->addKeyRewrite(PREDEF|CODE|HASH, ...)
$obj->addSchemaDirs(DIRECTORIES|FILENAME)
XML::Compile::RPC::Client->addSchemaDirs(DIRECTORIES|FILENAME)
$obj->addSchemas(XML, OPTIONS)
$obj->addTypemap(PAIR)
$obj->addTypemaps(PAIRS)
$obj->allowUndeclared([BOOLEAN])
$obj->blockNamespace(NAMESPACE|TYPE|HASH|CODE|ARRAY)
$obj->hooks
$obj->prefix(PREFIX)
$obj->prefixFor(URI)
$obj->prefixed(TYPE)
$obj->prefixes([PAIRS|ARRAY|HASH])
$obj->useSchema(SCHEMA, [SCHEMA])
Compilers
$obj->compile(('READER'|'WRITER'), TYPE, OPTIONS)
$obj->compileAll(['READER'|'WRITER'|'RW', [NAMESPACE]])
XML::Compile::RPC::Client->dataToXML(NODE|REF-XML-STRING|XML-STRING|FILENAME|FILEHANDLE|KNOWN)
$obj->reader(TYPE|NAME, OPTIONS)
$obj->template('XML'|'PERL', TYPE, OPTIONS)
$obj->writer(TYPE|NAME)
Administration
$obj->declare('READER'|'WRITER'|'RW', TYPE|ARRAY-of-TYPES, OPTIONS)
$obj->elements
$obj->findName(NAME)
$obj->findSchemaFile(FILENAME)
XML::Compile::RPC::Client->findSchemaFile(FILENAME)
$obj->importDefinitions(XMLDATA, OPTIONS)
$obj->knownNamespace(NAMESPACE|PAIRS)
XML::Compile::RPC::Client->knownNamespace(NAMESPACE|PAIRS)
$obj->namespaces
$obj->printIndex([FILEHANDLE], OPTIONS)
$obj->types
$obj->walkTree(NODE, CODE)
Handlers
$obj->call(METHOD, PARAM-(HASH|PAIR)S)
example:
my ($rc, $response) = $rpc->call('getQuote', string => 'IBM');
$rc == 0
or die "error: $response\n";
my $trace = $rpc->trace; # facts about the last call
# same call, via autoload. One simple parameter
my ($rc, $response) = $rpc->getQuote(string => 'IBM');
# function produces a HASH, one complex parameter
my $struct = struct_from_hash string => symbol => 'IBM';
my ($rc, $response) = $rpc->call('getQuote', $struct);
my ($rc, $response) = $rpc->getQuote($struct);
# or mixed simple and complex types
# Three parameters, of which two are complex structures.
my ($rc, $ans) = $rcp->someMethod($struct, int => 3, $struct2);
$obj->printTrace([FILEHANDLE])
Pretty print the trace, by default to STDERR.
$obj->trace
Returns a HASH with various facts about the last call; timings, the request and the response from the server. Be aware that LWP
will add some more header lines to the request before it is sent.
DETAILS
SEE ALSO
This module is part of XML-Compile-RPC distribution version 0.11, built on October 24, 2009. Website: http://perl.overmeer.net/xml-compile/
All modules in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::SOAP12, XML::Compile::SOAP::Daemon, XML::Compile::Tester, XML::Compile::Cache, XML::Compile::Dumper, XML::Compile::RPC, XML::Rewrite, and XML::LibXML::Simple.
Please post questions or ideas to the mailinglist at http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile For life contact with other developers, visit the #xml-compile
channel on irc.perl.org
.
LICENSE
Copyrights 2009 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html