ISA not working as expected in SOAP::Lite servlets

Paul Hirst <[email protected]>
Newsgroups gmane.comp.windows.devel.soap.general
Message-ID <[email protected]>
I haven't been able to find any information or examples which would clear
this up for me so apologies if this is a dumb question.

The problem is that I can't call a method in an object which is actually
defined in it's superclass. It returns the error Failed to locate method
(x) in class (y).

An example:

File: daemon
---------------------------------
#!/usr/bin/perl -w

use strict;
use warnings;
require Test::Test;
require Test::Root;

use SOAP::Transport::HTTP;

$SIG{PIPE} = 'IGNORE';

my $daemon = SOAP::Transport::HTTP::Daemon
  -> new (LocalPort => 8012, Reuse => 1)
  -> objects_by_reference(qw( Test::Test Test::Root ))
  -> dispatch_to(qw( Test::Test Test::Root ))
  -> options({compress_threshold => 10000})
;
print "Contact to SOAP server at ", $daemon->url, "\n";
$daemon->handle;
---------------------------------

File: Test/Test.pm
---------------------------------
package Test::Test;
require Test::Root;

our @ISA=qw( Test::Root );

sub foo {
      return "This is a foo\n";
}

1;
---------------------------------

File Test/Root.pm
---------------------------------
package Root;

sub bar {
      return "This is a bar\n";
}

1;
---------------------------------

File: client
---------------------------------
use SOAP::Lite;

my $s=SOAP::Lite->uri("http://soap.somewhere.net/Test/Test")->
      proxy("http://localhost:8012");

my $a=$s->foo;
print $a->faultstring."\n";
print $a->result;
$a=$s->bar;
print $a->faultstring."\n";
print $a->result;
---------------------------------

The client program prints out this:

This is a foo
Failed to locate method (bar) in class (Test::Test) at
/usr/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2195.

A slightly related problem is I was expecting to be able to return objects
and call them almost as normal objects (even though they are remote) but it
seems I have to create a SOAP::Lite object and pass my object as the first
argument to any function calls. Ie instead of:

my $myob=$remoteserver->createObject();
print $myob->foo();

I have to do

my $myob=$remoteserver->createObject();
my $soapcall=SOAP::Lite->uri("http://soap.somewhere.net/Myob")->
            proxy("http://blah.net/");
print $soapcall->foo($myob)->result;

I think I may be suffering from a fatal misunderstanding about how
everything fits together so any help or in depth examples involving
multiple classes and inheritance would be really useful.

My biggest problem is when I was using autodispatch everything appeared to
just work but now I need to talk to multiple soap servers in one piece of
code so autodispatch no longer seems sensiable.

Thanks in advance.


--
Paul Hirst, Virus Researcher                         Sophos Anti-Virus
email: [email protected]                     http://www.sophos.com

You can read messages from the SOAP archive, unsubscribe from SOAP, or subscribe to other
DevelopMentor lists at http://discuss.develop.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.