XMLRPC(3)

πŸ“¦
version 0.05 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

okay bestie, gather round, the manual page is XMLRPC(3) and the module living inside it is POE::Component::Server::XMLRPC β€” it's the little glow-up that lets you publish POE event handlers via XMLRPC over HTTP. that's the whole vibe. you write handlers, it puts them on the internet. slay. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole thing in one breath, no cap:

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

look at that. iconic behavior honestly. πŸ’…


🌸 DESCRIPTION 🌸

so POE::Component::Server::XMLRPC is a bolt-on component β€” a little accessory you snap onto your program β€” and what it does is publish a event handlers via XMLRPC over HTTP. yes. that's the whole job. it's giving "let the outside world call your event handlers".

there are four steps to making your programs support XMLRPC requests, bestie. four. count them with me:

  1. you must load the component.
  2. then you must instantiate it.
  3. every single POE::Component::Server::XMLRPC instance needs an alias to accept messages with, and a port to bind itself to.
  4. finally, your program should post a "publish" event to the server for each event handler it wishes to expose.

here's that in code, because vibes alone don't compile:

use POE::Component::Server::XMLRPC
POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 32080 );
$kernel->post( xmlrpc => publish => session_alias => "methodName" );
lowkey note: yeah, the first line there is missing its semicolon in the original and we are not touching it. preserving the artifact. museum rules. πŸ›οΈ

later β€” whenever you feel like it, no pressure β€” you can make those events private again:

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

πŸŽ€ writing the handler (the main character part) πŸŽ€

finally you must write the XMLRPC request handler. this is your moment. XMLRPC handlers receive a single parameter, ARG0, and inside it is a XMLRPC transaction object.

that object has two methods, bestie, and they are everything:

  • params() β€” returns a reference to the XMLRPC parameters. that's the tea you got handed.
  • return() β€” returns its parameters to the client as a XMLRPC response. that's you handing the tea back.

here's the shape of it:

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

🫢


πŸ’œ the client side, because you need someone to call you πŸ’œ

and here is a sample XMLRPC::Lite client. it should work with the server up in the SYNOPSIS. yes, really, they match. periodt.

#!/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";
πŸ’€ not pring. we know. we see it. we are leaving it exactly where it is. it's part of the lore now.

😭 BUGS 😭

okay so the origin story: this project is a modified version of POE::Component::Server::SOAP by Rocco Caputo. and 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.

and thanks to his code, this module got made in one day β€” and it was only the second day of using POE. genuinely unhinged. iconic. anyway:

⚠️ there's gotta be bugs here. please use http://rt.cpan.org/ to report them. do not suffer in silence, bestie. speak up.

🌈 SEE ALSO 🌈

  • the examples directory that came with this component. go look. it's right there.
  • XMLRPC::Lite
  • POE::Component::Server::SOAP
  • POE::Component::Server::HTTP
  • POE

iykyk πŸ‘‘


πŸ‘‘ AUTHOR & COPYRIGHTS πŸ‘‘

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. πŸ’–


and that's the whole page, babes β€” this one's from the perl v5.42.0 era, dated 2025-07-25, filed under XMLRPC(3). go publish something. mwah. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from