|
NAMEXML::RPC::Enc - Base class for XML::RPC encodersSYNOPSISGeneric usageuse 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 ); METHODSThe following methods should be implementednew (%args)Should support arguments:
request ($method, @args) : xml byte-stream, [ new call url ]Encode request into XMLresponse (@args) : xml byte-streamEncode response into XMLfault ($faultcode, $faultstring) : xml byte-streamEncode fault into XMLregisterClass ($class_name,$encoder_cb)Register encoders for custom Perl typesEncoders 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 ($xml) : $methodname, @argsDecode request xmldecode ($xml) : @argsDecode response xmldecode ($xml) : { fault => { faultCode => ..., faultString => ... } }Decode fault xmlregisterType ($xmlrpc_type,$decoder_cb)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 & LICENSECopyright (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. AUTHORMons Anderson, "<mons@cpan.org>"
Visit the GSP FreeBSD Man Page Interface. |