XML::RPC::Enc - Base class for XML::RPC encoders
Generic usage
use XML::RPC::Fast; my $server = XML::RPC::Fast->new( undef, encoder => XML::RPC::Enc::LibXML->new ); my $client = XML::RPC::Fast->new( $uri, encoder => XML::RPC::Enc::LibXML->new );
The following methods should be implemented
Should support arguments:
Internal encoding. undef means wide perl characters (perl-5.8.1+)
undef
External encoding. Which encoding to use in composed XML
Encode request into XML
Encode response into XML
Encode fault into XML
Register encoders for custom Perl types
Encoders description:
# Generic: $simple_encoder_cb = sub { my $object = shift; # ... return type => $string; }; # Encoder-dependent (XML::RPC::Enc::LibXML) $complex_encoder_cb = sub { my $object = shift; # ... return XML::LibXML::Node; };
Samples:
$enc->registerClass( DateTime => sub { return ( 'dateTime.iso8601' => $_[0]->strftime('%Y%m%dT%H%M%S.%3N%z') ); }); # Encoder-dependent (XML::RPC::Enc::LibXML) $enc->registerClass( DateTime => sub { my $node = XML::LibXML::Element->new('dateTime.iso8601'); $node->appendText($_[0]->strftime('%Y%m%dT%H%M%S.%3N%z')); return $node; });
Decode request xml
Decode response xml
Decode fault xml
Register decoders for XML-RPC types
$decoder_cb is depends on encoder implementation.
Samples for XML::RPC::Enc::LibXML
$enc->registerType( base64 => sub { my $node = shift; return MIME::Base64::decode($node->textContent); }); $enc->registerType( 'dateTime.iso8601' => sub { my $node = shift; return DateTime::Format::ISO8601->parse_datetime($node->textContent); });
Copyright (c) 2008-2009 Mons Anderson.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Mons Anderson, <mons@cpan.org>
<mons@cpan.org>
To install XML::RPC::Fast, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::RPC::Fast
CPAN shell
perl -MCPAN -e shell install XML::RPC::Fast
For more information on module installation, please visit the detailed CPAN module installation guide.