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
XMLRPC(3) User Contributed Perl Documentation XMLRPC(3)

POE::Component::Server::XMLRPC - publish POE event handlers via XMLRPC over HTTP

  use POE;
  use POE::Component::Server::XMLRPC;

  POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 32080 );

  POE::Session->create
    ( inline_states =>
      { _start => \&setup_service,
        _stop  => \&shutdown_service,
        sum_things => \&do_sum,
      }
    );

  $poe_kernel->run;
  exit 0;

  sub setup_service {
    my $kernel = $_[KERNEL];
    $kernel->alias_set("service");
    $kernel->post( xmlrpc => publish => service => "sum_things" );
  }

  sub shutdown_service {
    $_[KERNEL]->post( xmlrpc => rescind => service => "sum_things" );
  }

  sub do_sum {
    my $transaction = $_[ARG0];
    my $params = $transaction->params();
    my $sum = 0;
    for(@{$params}) {
      $sum += $_;
    }
    $transaction->return("Thanks.  Sum is: $sum");
  }

POE::Component::Server::XMLRPC is a bolt-on component that can publish a event handlers via XMLRPC over HTTP.

There are four steps to enabling your programs to support XMLRPC requests. First you must load the component. Then you must instantiate it. Each POE::Component::Server::XMLRPC instance requires an alias to accept messages with and a port to bind itself to. Finally, your program should posts a "publish" events to the server for each event handler it wishes to expose.

  use POE::Component::Server::XMLRPC
  POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 32080 );
  $kernel->post( xmlrpc => publish => session_alias => "methodName" );

Later you can make events private again.

  $kernel->post( xmlrpc => rescind => session_alias => "methodName" );

Finally you must write the XMLRPC request handler. XMLRPC handlers receive a single parameter, ARG0, which contains a XMLRPC transaction object. The object has two methods: params(), which returns a reference to the XMLRPC parameters; and return(), which returns its parameters to the client as a XMLRPC response.

  sum_things => sub {
    my $transaction = $_[ARG0];
    my $params = $transaction->params();
    my $sum = 0;
    while (@{$params})
      $sum += $value;
    }
    $transaction->return("Thanks.  Sum is: $sum");
  }

And here is a sample XMLRPC::Lite client. It should work with the server in the SYNOPSIS.

  #!/usr/bin/perl

  use warnings;
  use strict;

  use XMLRPC::Lite;

  print XMLRPC::Lite
    -> proxy('http://poe.dynodns.net:32080/?session=sum_server')
    -> sum_things(8,6,7,5,3,0,9)
    -> result
    ;
  pring "\n";

This project is a modified version of POE::Component::Server::SOAP by Rocco Caputo. Of that, he writes:

  This project was created over the course of two days, which attests to
  the ease of writing new POE components.  However, I did not learn XMLRPC
  in depth, so I am probably not doing things the best they could.

Thanks to his code, I've managed to create this module in one day (on only my second day of using POE). There's gotta be bugs here. Please use http://rt.cpan.org/ to report them.

The examples directory that came with this component.

XMLRPC::Lite POE::Component::Server::SOAP POE::Component::Server::HTTP POE

POE::Component::Server::XMLRPC is Copyright 2002 by Mark A. Hershberger. All rights are reserved. POE::Component::Server::XMLRPC is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
2003-03-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

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