[Melbourne-pm] SOAP::Lite Serializing Complex objects.

Mathew Robertson mathew.robertson at netratings.com.au
Mon Jan 23 17:09:19 PST 2006

Hi there,

I haven't used SOAP::Lite, but I had a quite look at the module code -> 
it appears that you shouldn't be using 'ns1' as a prefix.

Not sure if this helps,

Daniel Golembo wrote:

>I have a problem serializing complex objects while using SOAP::Lite.  
>The issue is, if I have a complex object, that iteslf contains a complex 
>object, the second object does not get correctly encoded in the SOAP 
>For Example, I have an object that needs to be sent as an argument in a 
>SOAP call:
>my $expression = bless( {
>                 'descriptor' => bless( {
>                                        'sum' => '1000',
>                                        'description' => 'Adding 900 to 100'
>                                      }, 'sample_Descriptor' ),
>                 'a' => '900',
>                 'b' => '100',
>                 'dateAdded' => '2006-01-23T03:32:03.781Z'
>               }, 'sample_SumExpression' );
>and I have SOAP serializer functions to serialize sample_SumExpression 
>and sample_Descriptor like:
>sub SOAP::Serializer::as_sample_SumExpression {
>    my $self = shift;
>    my($value, $name, $type, $attr) = @_;
>    my $a=SOAP::Data->new(value=>$value->{a}, type=>'string');
>    my $b=SOAP::Data->new(value=>$value->{b}, type=>'string');
>    my $dateAdded=SOAP::Data->new(value=>$value->{dateAdded}, 
>    my $descriptor=SOAP::Data->new(value=>$value->{descriptor}, 
>    my $rval=[$name, {'xsi:type'=>'ns1:sample_SumExpression', %$attr}, 
>{a=>$a, b=>$b, dateAdded=>$dateAdded, descriptor=>$descriptor}];
>    return $rval;
>sub SOAP::Serializer::as_sample_Descriptor {
>    print "Firing SOAP::Serializer::as_unimelb_merlin_Descriptor\n";
>    my $self = shift;
>    my($value, $name, $type, $attr) = @_;
>    my $description=SOAP::Data->new(name=>'description', 
>value=>$value->{description}, type=>'string');
>    my $sum=SOAP::Data->new(name=>'sum', value=>$value->{sum}, type=>'int');
>    my $rval=[$name, {'xsi:type'=>'ns1:sample_Descriptor', %$attr}, 
>{description=>$description, sum=>$sum}];
>    return $rval;
>When SOAP call happens, the envelope that is generated by SOAP::Lite is:
><?xml version="1.0" encoding="UTF-8"?><soap:Envelope 
>xsi:type="xsd:string">900</a><b xsi:type="xsd:string">100</b><dateAdded 
>So, the Top level object, sample_Expression, gets encoded correctly, but 
>the lower level object, sample_Descriptor, is not.
>I have also tried using encode_object function of SOAP::Serializer, but 
>this resulted in sample_Descriptor being encoded as an array.
>I wonder what I am doing wrong or what SOAP::Lite is doing wrong.  
>Please help.
>Melbourne-pm mailing list
>Melbourne-pm at pm.org

More information about the Melbourne-pm mailing list