Subject: | serialization and autotype 'off' |
Date: | Mon, 29 Sep 2008 10:50:51 +0200 |
To: | <bug-SOAP-Lite [...] rt.cpan.org> |
From: | "Buchetmann, Christoph (EBV)" <Christoph.Buchetmann [...] ebv.com> |
Modul version: SOAP-Lite-0.710.08
Perl: v5.10.0 built for IA64.ARCHREV_0-thread-multi-LP64
I have found a problem with serialization and autotype 'off'. All array
elements seems to vanish.
The following unit test schould explain my problem:
use strict; use warnings;
use Test::More tests => 1;
use SOAP::Lite;
use Test::Differences;
my $serializer = SOAP::Serializer->new()->autotype(1);
my @som_data = ( SOAP::Data->name('Spec'), SOAP::Data->name('Version')
);
my $complex_data = SOAP::Data->name( 'complex' )
->attr( { attr => '123' } )
->value( [ SOAP::Data->name('Spec'), SOAP::Data->name('Version') ]
);
my $result = $serializer->encode_object($complex_data, 'test', undef,
{});
# remove attributes created by autotype
delete $result->[1]->{'soapenc:arrayType'};
delete $result->[1]->{'xsi:type'};
# turn off autotyping
$serializer->autotype(0);
# now we are able to compare both kinds of serialization
eq_or_diff( $result,
$serializer->encode_object($complex_data, 'test', undef,
{}),
'autotype off array serialization');
__END__
If I patch in SOAP/Lite.pm the method encode_literal_array with
...
if (!$self->autotype) {
$name ||= gen_name;
my @items = map {$self->encode_object($_, $name)} @$array;
return [ $name, {%$attr}, [@items], $self->gen_id($array) ];
}
...
the unit test is successful.