Author image Evangelo Prodromou


JOAP::Proxy - Base class for client-side proxies of JOAP objects


  use Net::Jabber qw(Client);
  use JOAP::Proxy;

  # set up a Net::Jabber connection (your responsibility)

  sub jabber_con {

    my $user = shift;
    my $server = shift;
    my $password = shift;
    my $port = shift || 5222;
    my $resource = shift || 'JOAPProxy';

    if (!$user || !$server || !$password) {
        return undef;

    my $con = new Net::Jabber::Client;

    my $status = $con->Connect(hostname => $server,
                               port => $port);

    if (!(defined($status))) {
        return undef;

    my @result = $con->AuthSend(username => $user,
                                password => $password,
                                resource => $resource);

    if ($result[0] ne "ok") {
        return undef;

    $con->PresenceSend(priority => 0);

    return $con;

  my $con = jabber_con('me', '', 'very secret') ||
    die("Can't connect.");

  # Make that available to all proxy objects



This is an abstract base class for local, client-side proxies to remote JOAP objects -- object servers, classes, and instances. It provides some default behavior for subclasses, and contains a class variable for Jabber connectivity, but otherwise it should not be used directly.


All of the classes that proxy for remote JOAP objects are subclasses of JOAP::Proxy. This package defines a lot of common behavior, but almost none of it should be used directly. Consequently, the appropriate methods and such are documented in the subclasses; see below for links to these classes.

Class Methods

There's really only one method in this package that you should care about, and that's the one to set up the Jabber connection used by all the proxies.


This is the Jabber connection used to send and receive messages about proxy information. You should use this method as a mutator in your programs as early as possible, and definitely before using any of the other proxy classes.

The argument $con is a Net::Jabber::Protocol object. It can be a Net::Jabber::Client object or a Net::Jabber::Component object, and possibly even a Net::Jabber::Server object if you're adventurous.

The synopsis above has a good example of setting up the connection. You should avoid setting any callbacks on the connection, or at least setting any that interfere with JOAP's namespace or the 'jabber:iq:rpc' namespace.

This is a translucent, inheritable class data accessor. What that means is that you can, in theory, set the Connection class attribute for subclasses of this package, and it will only affect that subclass. For example:

  package FooProxy;
  use JOAP::Proxy::Package::Class;
  use base qw(JOAP::Proxy::Package::Class);

  FooProxy->Address(''); # say what class this is proxying for

  package main;

  # set up the connection for all proxies

  my $con1 = jabber_con('me', '', 'very secret') ||
    die("Can't connect.");


  # set up a different connection just for foo proxies

  my $con2 = jabber_con('you', '', 'also secret') ||
    die("Can't connect.");


This is pretty untested, and I wouldn't rely on it too much if I were you. But the possibility is there to use different connections for different proxy packages.


None by default.


You can create a proxy for a remote JOAP object server using JOAP::Proxy::Package::Server (preferred) or JOAP::Proxy::Server.

You can create a proxy for a remote JOAP class using JOAP::Proxy::Package::Class (preferred) or JOAP::Proxy::Class.

You can create a proxy for a remote JOAP instance using JOAP::Proxy::Package::Class (preferred) or JOAP::Proxy::Instance.

JOAP has more general JOAP information, as well as bug-reporting and contact information.

Net::Jabber has more information on setting up, and tearing down, Jabber connections.


Evan Prodromou <>


Copyright (c) 2003, Evan Prodromou <>.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA