GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  XML::RPC::ENC (3)

.ds Aq ’

NAME

XML::RPC::Enc - Base class for XML::RPC encoders

CONTENTS

SYNOPSIS

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 );



METHODS

The following methods should be implemented

    new (%args)

Should support arguments:
internal_encoding [ = undef ] Internal encoding. undef means wide perl characters (perl-5.8.1+)
external_encoding [ = utf-8 ] External encoding. Which encoding to use in composed XML

request ($method, CW@args) : xml byte-stream, [ new call url ]

Encode request into XML

    response (@args) : xml byte-stream

Encode response into XML

fault ($faultcode, CW$faultstring) : xml byte-stream

Encode fault into XML

    registerClass ($class_name,$encoder_cb)

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 ($xml) : CW$methodname, CW@args

Decode request xml

decode ($xml) : CW@args

Decode response xml

    decode ($xml) : { fault => { faultCode => ..., faultString => ... } }

Decode fault xml

    registerType ($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 & LICENSE

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.

AUTHOR

Mons Anderson, <mons@cpan.org>
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 XML::RPC::ENC (3) 2011-10-19

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.