[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Help with SOAP::Lite Object syntax
- Subject: [ale] Help with SOAP::Lite Object syntax
- From: rekoil at semihuman.com (Chris Woodfield)
- Date: Wed, 12 Mar 2008 21:02:06 -0400
Hi all,
I'm trying to figure out how to use SOAP::Lite in an object syntax.
There's obviously something fundamental I'm missing, and I was
wondering if anyone clueful could point me to it...
First off, this is how I'm used to building objects locally - nothing
fancy here:
------
/usr/bin/perl -w
BEGIN {
package TestClass;
sub new {
my $class = shift;
my $self = {};
$self->{testval} = "test";
return (bless ($self, $class));
}
sub test {
my $self = shift;
return $self->{testval};
}
}
my $testobj = new TestClass;
print $testobj->test() . "\n";
-----
Running this returns the "test" string as it should.
However, the same function adapted for a SOAP call using SOAP::Lite
gives me errors with similar syntax:
Server side:
#!/usr/bin/perl -w
use strict;
use SOAP::Transport::HTTP;
my $daemon = new SOAP::Transport::HTTP::Daemon (LocalPort => 8080);
$daemon->dispatch_to('Test');
$daemon->handle;
BEGIN {
package Test;
sub new {
my $class = shift;
my $self = {};
$self->{testval} = "test";
return (bless ($self, $class));
}
sub test {
my $self = shift;
return $self->{testval};
}
}
Client side:
-----
#!/usr/bin/perl -w
use strict;
use SOAP::Lite;
my $testobj = new SOAP::Lite
->ns('http://test.server.com:8080/Test')
->proxy('http://test.server.com:8080');
my $query = $testobj->test();
if ($query->fault) {
print "Error: (" . $query->faultcode() . ") " . $query-
>faultstring() . "\n";
}
print $query->result . "\n";
-----
When I run this I get:
Error: (soap:Server) Can't use string ("Test") as a HASH ref while
"strict refs" in use at soaptestserver2.pl line 23.
Sure enough, if I add the line "print Data::Dumper($self) in the
test() function, I get:
$VAR1 = 'Test';
So it's obvious that no actual object is getting passed around, just
the class name.
I'm obviously missing something rather fundamental here. Is it even
possible to do what I'm trying to do? If so, what am I doing wrong?
TIA,
-Chris