Subject: | Unable to get SOAP::Lite to serialize a 1-D array of strings |
Date: | Sun, 19 Oct 2008 20:07:49 -0700 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Tim Wood <timwood0 [...] pacbell.net> |
I am unable to get SOAP::Lite 0.710.0x to serialize a 1-D array of strings. V 0.60 did it, but would only tag both name & type with the namespace, or both not, which was incompatible with my application server. Test case in brief:
---
my ($proto, %ctorArgs) = @_; # Object reference & ctor args ...
my $proxy = SOAP::Lite->service($ctorArgs{'serviceURL'})->xmlschema(2001)
->uri($ctorArgs{'endpointURI'}); ...
# Take an argument list and wrap it in a SOAP::Data.
sub soapifyList {
return SOAP::Data->new()->value(@_);
}
# Call remote myMethod1 with plain string arg1 and SOAP::Data-wrapped array.
my $soapedArg2Array = soapifyList(9, 1);
# Also NB, SOAP::Lite 0.710.0x does not let you pass a SOAP::Data holder containing $arg1,
# unlike 0.60. It returns "String value expected instead of SOAP::Data reference".
my $result = $proxy->myMethod1($arg1, $soapedArg2Array); ...
---
The XML generated for the call goes like this (my comment and folding added):
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:tns="urn:Foo1"
xmlns:ns2="http://java.sun.com/jax-rpc-ri/internal"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body><tns:myMethod1>
<String_1 xsi:type="xsd:string">+22522522552</String_1>
<!-- ALWAYS A NIL ARRAY --><arrayOfString_2 xsi:nil="true" xsi:type="tns:ArrayOfstring" />
</tns:myMethod1></soap:Body>
</soap:Envelope>
The server side accepts this call and returns a correct result given the parameters, and the client side continues. So the old 0.60 problem with ns tags is fixed. But now I am unable to get the client to supply the array data in 0.710.0x.
The same XML and bug occur if I do:
my $soapedArg2Array = [ 9, 1 ];
and
my $soapedArg2Array = soapifyList(soapifyList(9), soapifyList(1));
and
my $soapedArg2Array = [ soapifyList(9), soapifyList(1) ];
Line 1535 of Lite.pm reads:
# This is breaking a unit test right now...
# proposed resolution for [ 1700326 ] encode_data called incorrectly in envelope
# $body->set_value(SOAP::Utils::encode_data($parameters ? \$parameters : ()))
# if $body; # must call encode_data on nothing to enforce xsi:nil="true" to be set.
This suggests the code thinks the supplied SOAP::Data value for the array holds a nil (undef) but I've established that's not the case.