resistance is obsolete ™ ;-)
the groupware construction kit

Some Information for Accessing XML-RPC using Perl

Some old (2001) instructions for accessing XML-RPC using Perl. Also take a look at the XML-RPC Perl tutorial on xml-rpc.com !

Update 2003-01-29

According to a customer the information below is indeed outdated ;-) Apparently the Frontier module is not available anymore, instead you can use the SOAP::Lite module which not only provides SOAP, but also XML-RPC client functionality.
A small code snippet to access OpenGroupware.org:

use XMLRPC::Lite;
use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1;
> my $fkt = "person.getById";
my $para = "10000";
> my $result = XMLRPC::Lite
-> proxy('http://root:rootpwd@165.0.0.10:20000')
-> $fkt($para);
print Dumper($result->paramsall), '';
Thanks to Mr. Hanusch for providing this information !

XMLRPC support for Perl - README

Installation

To use XMLRPC with Perl, you first need these Perl modules installed on your machine (SuSE 7.2 tested) :

  • perl-libwww-perl
  • perl-XML-Parser
Also you need the Frontier::XMLRPC module, which is available at
http://bitsko.slc.ut.us/~ken/xml-rpc/ (down)
or at
http://www.cpan.org/authors/KMACLEOD/Frontier-RPC-0.06.tar.gz

If you untar'ed and ungzip'ed the package, you just need to issue the following commands to install the client on your system :

  • perl Makefile.PL
  • make
  • make test (check if everything is OK here)
  • make install (you should be 'root')
Now everything should be ready to run Perl scripts with XMLRPC support.

How to use it

To show you how to use Perl and XMLRPC to access a OGo server, here's a little code example that shows the essential steps.

#!/usr/bin/perl
# 'include' the XMLRPC client
use Frontier::Client;
# init the client with the target url, login & password
$client = Frontier::Client->new( url => "http://login:password@your.server.com:10000");
# send a message to fetch persons with a name like 'zaphod',
# store the result in @result
@result = $client->call('person.fetch',"name like \'*zaphod*\'");
# check how many records we received
$count = @{$result[0]}; # iterate over the results
for $i (0 .. $count-1)
{
# get the current element
$element = $result[0]->[$i];
# get the name of the current element
$name = $element->{"name"};
}
We welcome your feedback!
Trademarks.  
This site is sponsored by
SKYRIX Software AG
ZideOne GmbH
MDlink