Subject: | Multiple array-refs in SOAP calls |
Date: | Wed, 13 Feb 2008 17:54:58 +0000 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Dan Rowles <d.rowles [...] outcometechnologies.com> |
Hello,
There is a bug in SOAP::Lite version 0.69 that is not present in version
0.60a, which occurs when you pass two array-refs as the arguments to a
function over SOAP. I have included some scripts with this email to
demonstrate the problem.
The attached "server.pl" script starts up a daemon, listening on port
10000, which will accept SOAP requests from a client. Only one method is
provided, "echo", which returns whatever arguments it is given.
The "client.pl" script connects to the server, and calls the "echo"
method, passing in four arguments, which are as follows:-
my @args = ("hi", ["bob", "bobbage"], ["jim", "jimmage"], "bye");
To run these scripts:-
$ perl server.pl &
$ perl client.pl
Under SOAP::Lite 0.60a, the following (correct) output appears:-
$VAR1 = 'hi';
$VAR2 = [
'bob',
'bobbage'
];
$VAR3 = [
'jim',
'jimmage'
];
$VAR4 = 'bye';
Under SOAP::Lite 0.69, the following (invalid) output appears:-
$VAR1 = 'hi';
$VAR2 = [
'bob',
'bobbage',
[
'jim',
'jimmage'
],
$VAR2->[2]
];
$VAR3 = $VAR2->[2];
$VAR4 = 'bye';
The third attached file, "test-serialize.pl", demonstrates the bug using
just the SOAP::Serializer and SOAP::Deserializer classes (without
needing to start a SOAP server).
Thanks,
--
Dan Rowles
Outcome Technologies Ltd
BUPA House, 15-19 Bloomsbury Way, London WC1A 2BA
Registered in England, No: 3829851
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use SOAP::Transport::HTTP;
my $daemon = SOAP::Transport::HTTP::Daemon->new(
LocalAddr => "127.0.0.1", LocalPort => 10000, Reuse => 1,
);
$daemon->dispatch_to("My::Test::Class");
$daemon->serializer->readable(1);
$daemon->handle;
package My::Test::Class;
sub echo {
my($class, @args) = @_;
print STDERR "CALLED THE 'echo()' method ($class)\n";
print STDERR " ARGS: ", Data::Dumper::Dumper(@args), " +DONE\n";
return @args;
}
1;
__END__
#! /usr/bin/perl
use strict;
use warnings;
use SOAP::Lite;
use Data::Dumper;
my $soap = SOAP::Lite->new();
my $xmlns = "http://localhost/My/Test/Class";
$soap->proxy("http://localhost:10000");
$soap->uri($xmlns);
$soap->readable(1);
my $meth = "echo";
my @args = ("hi", ["bob", "bobbage"], ["jim", "jimmage"], "bye");
my $resp = $soap->call($meth, @args);
unless($resp && ref($resp) && $resp->isa("SOAP::SOM")) {
die "Invalid response: ", Dumper($resp);
}
my @res = $resp->paramsall;
print "GOT: ", Dumper(@res), " +DONE\n";
exit 0;
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use SOAP::Lite;
my $xml = <<"";
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<echo xmlns="http://localhost/My/Test/Class">
<!-- soapenc:arrayType="xsd:anyType[4]" xsi:type="soapenc:Array"> -->
<c-gensym3 xsi:type="xsd:string">hi</c-gensym3>
<soapenc:Array soapenc:arrayType="xsd:string[2]" xsi:type="soapenc:Array">
<item xsi:type="xsd:string">bob</item>
<item xsi:type="xsd:string">bobbage</item>
</soapenc:Array>
<soapenc:Array soapenc:arrayType="xsd:string[2]" xsi:type="soapenc:Array">
<item xsi:type="xsd:string">jim</item>
<item xsi:type="xsd:string">jimmage</item>
</soapenc:Array>
<c-gensym7 xsi:type="xsd:string">bye</c-gensym7>
</echo>
</soap:Body>
</soap:Envelope>
my $deser = SOAP::Deserializer->new();
$deser->hrefs({});
$deser->ids({});
my $parsed = $deser->decode($xml);
$deser->ids($parsed);
my $tmp = $deser->decode_object($parsed);
die Dumper($tmp, $parsed);
my $som = SOAP::Deserializer->deserialize($xml);
my @res = $som->paramsall;
print "GOT: ", Dumper(@res), " +DONE\n";
exit 0;