I took the following code from the perldoc pages for SOAP::Lite, and when it is run I get the following error:
Not a HASH reference at /usr/local/share/perl/5.10.0/SOAP/Lite.pm line 3753.
test2.pl (client) :
#!/usr/bin/perl
use warnings;
use strict;
use SOAP::Lite +autodispatch =>
uri => 'http://localhost/Demo',
proxy => 'http://localhost/~david/cgi-bin/soap/soapobj.cgi';
# using SOAP calls as objects
my $t = Demo->new(100);
print($t->nxt,"\n");
soapobj.cgi (server):
#!/usr/bin/perl
use warnings;
use strict;
use SOAP::Lite +autodispatch =>
uri => 'http://localhost/Demo',
proxy => 'http://localhost/~david/cgi-bin/soap/soapobj.cgi';
# using SOAP calls as objects
my $t = Demo->new(100);
print($t->nxt,"\n");
SOAP client
sorry, cut and paste error when copying in server code.
soapobj.cgi (server):
#!/usr/bin/perl
use warnings;
use strict;
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('Demo')
-> handle;
package Demo;
sub new {
my $self = shift;
my $class = ref($self) || $self;
bless {_num => shift} => $class;
}
sub nxt {
my $self = shift;
$self->{_num}++;
return $self->{_num};
}
The following code without autodispatch does work:
--------------
my $s = SOAP::Lite->new(
uri => 'http://localhost/Demo',
proxy => 'http://localhost/~david/cgi-bin/soap/soapobj.cgi'
);
# using SOAP calls as objects
my $t = $s->call(new => 123)->result;
my $d = SOAP::Data->value($t);
print("result: ".$s->nxt($d)->result,"\n");
---------------
output is correct:
result: 124