XML::Compile::RPC::Util - XML-RPC convenience functions
XML::Compile::RPC::Util is a Exporter
use XML::Compile::RPC::Util; my $h = struct_to_hash $d->{struct}; my @r = struct_to_rows $d->{struct}; my $d = struct_from_rows @r; my $d = struct_from_hash int => %h; my @a = rpcarray_values $d->{array}; my $d = rpcarray_from int => @a; my $rc = fault_code $d->{fault}; my ($rc, $rcmsg) = fault_code $d->{fault}; my $d = fault_from $rc, $msg;
Only usable when all key-value pairs are of the same type, usually string. The keys are included alphabetically.
string
example:
my $data = struct_from_hash int => { begin => 3, end => 5 };
Each ROW is an ARRAY which contains member name, member type, and member value. Returned is a structure.
$d = struct_from_rows [symbol => string => 'RHAT'] , [limit => double => 2.25]; print Dumper $d;
prints:
{ struct => { member => [ { name => 'symbol', value => {string => 'RHAT' }} , { name => 'limit', value => {double => 2.25} } ] }};
which will become in XML
<struct> <member> <name>symbol</name> <value><string>RHAT</string></value> </member> <member> <name>limit</name> <value><double>2.25</double></value> </member> </struct>
Returns a HASH containing the structure information. The order of the keys and type of the values is lost. When keys appear more than once, only the last one is kept.
if(my $s = $d->{struct}) { my $h = struct_to_hash $s; print "$h->{limit}\n"; }
Returns a LIST of all the members of the structure. Each element of the returned LIST is an ARRAY with contains three fields: member name, member type and member value.
if(my $s = $d->{struct}) { my @rows = struct_to_rows $s; foreach my $row (@rows) { my ($key, $type, $value) = @$row; print "$key: $value ($type)\n"; } }
Construct an rpc-array structure from a LIST of values. These values must all have the same type.
my $d = rpcarray_from int => @a;
Remove all array information except the values fron an RPC-array structure. Actually, only the type information is lost: the other components of the complex XML structure are overhead.
if(my $a = $d->{array}) { my @v = rpcarray_values $a; }
In LIST context, it returns both the integer faultCode as the corresponding faultString. In SCALAR context, only the code.
When the faultCode is 0, the value of -1 will be returned. Some servers (like ExistDB 1.4) accidentally forget to set a good numeric value.
0
-1
if(my $f = $d->{fault}) { my ($rc, $rcmsg) = fault_code $f; my $rc = fault_code $f; }
Construct a fault structure from an error code and the related error STRING.
my $d = fault_from 42,'no answer';
This module is part of XML-Compile-RPC distribution version 0.17, built on September 12, 2013. Website: http://perl.overmeer.net/xml-compile/
Other distributions in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::SOAP12, XML::Compile::SOAP::Daemon, XML::Compile::SOAP::WSA, XML::Compile::C14N, XML::Compile::WSS, XML::Compile::WSS::Signature, 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 live contact with other developers, visit the #xml-compile channel on irc.perl.org.
#xml-compile
irc.perl.org
Copyrights 2009-2013 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
To install XML::Compile::RPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Compile::RPC
CPAN shell
perl -MCPAN -e shell install XML::Compile::RPC
For more information on module installation, please visit the detailed CPAN module installation guide.