1XMLRPC(3)             User Contributed Perl Documentation            XMLRPC(3)
2
3
4

NAME

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

SYNOPSIS

10         use POE;
11         use POE::Component::Server::XMLRPC;
12
13         POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 32080 );
14
15         POE::Session->create
16           ( inline_states =>
17             { _start => \&setup_service,
18               _stop  => \&shutdown_service,
19               sum_things => \&do_sum,
20             }
21           );
22
23         $poe_kernel->run;
24         exit 0;
25
26         sub setup_service {
27           my $kernel = $_[KERNEL];
28           $kernel->alias_set("service");
29           $kernel->post( xmlrpc => publish => service => "sum_things" );
30         }
31
32         sub shutdown_service {
33           $_[KERNEL]->post( xmlrpc => rescind => service => "sum_things" );
34         }
35
36         sub do_sum {
37           my $transaction = $_[ARG0];
38           my $params = $transaction->params();
39           my $sum = 0;
40           for(@{$params}) {
41             $sum += $_;
42           }
43           $transaction->return("Thanks.  Sum is: $sum");
44         }
45

DESCRIPTION

47       POE::Component::Server::XMLRPC is a bolt-on component that can publish
48       a event handlers via XMLRPC over HTTP.
49
50       There are four steps to enabling your programs to support XMLRPC
51       requests.  First you must load the component.  Then you must
52       instantiate it.  Each POE::Component::Server::XMLRPC instance requires
53       an alias to accept messages with and a port to bind itself to.
54       Finally, your program should posts a "publish" events to the server for
55       each event handler it wishes to expose.
56
57         use POE::Component::Server::XMLRPC
58         POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 32080 );
59         $kernel->post( xmlrpc => publish => session_alias => "methodName" );
60
61       Later you can make events private again.
62
63         $kernel->post( xmlrpc => rescind => session_alias => "methodName" );
64
65       Finally you must write the XMLRPC request handler.  XMLRPC handlers
66       receive a single parameter, ARG0, which contains a XMLRPC transaction
67       object.  The object has two methods: params(), which returns a
68       reference to the XMLRPC parameters; and return(), which returns its
69       parameters to the client as a XMLRPC response.
70
71         sum_things => sub {
72           my $transaction = $_[ARG0];
73           my $params = $transaction->params();
74           my $sum = 0;
75           while (@{$params})
76             $sum += $value;
77           }
78           $transaction->return("Thanks.  Sum is: $sum");
79         }
80
81       And here is a sample XMLRPC::Lite client.  It should work with the
82       server in the SYNOPSIS.
83
84         #!/usr/bin/perl
85
86         use warnings;
87         use strict;
88
89         use XMLRPC::Lite;
90
91         print XMLRPC::Lite
92           -> proxy('http://poe.dynodns.net:32080/?session=sum_server')
93           -> sum_things(8,6,7,5,3,0,9)
94           -> result
95           ;
96         pring "\n";
97

BUGS

99       This project is a modified version of POE::Component::Server::SOAP by
100       Rocco Caputo.  Of that, he writes:
101
102         This project was created over the course of two days, which attests to
103         the ease of writing new POE components.  However, I did not learn XMLRPC
104         in depth, so I am probably not doing things the best they could.
105
106       Thanks to his code, I've managed to create this module in one day (on
107       only my second day of using POE).  There's gotta be bugs here.  Please
108       use http://rt.cpan.org/ to report them.
109

SEE ALSO

111       The examples directory that came with this component.
112
113       XMLRPC::Lite POE::Component::Server::SOAP POE::Component::Server::HTTP
114       POE
115

AUTHOR & COPYRIGHTS

117       POE::Component::Server::XMLRPC is Copyright 2002 by Mark A.
118       Hershberger.  All rights are reserved.  POE::Component::Server::XMLRPC
119       is free software; you may redistribute it and/or modify it under the
120       same terms as Perl itself.
121
122
123
124perl v5.28.1                      2003-03-20                         XMLRPC(3)
Impressum