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

Kathryn_M_Grant@national.com.au Kathryn_M_Grant at national.com.au
Sun Jan 22 20:28:38 PST 2006


Hi Daniel
I have encountered the exact same problem with nested complex objects, and
never managed to get the damn thing to work.
Hope you have better luck!

Kat




                                                                           
             Daniel Golembo                                                
             <dgolembo at unimelb                                             
             .edu.au>                                                   To 
             Sent by:                  melbourne-pm at pm.org                 
             melbourne-pm-boun                                          cc 
             ces+kathryn_m_gra                                             
             nt=national.com.a                                     Subject 
             u at pm.org                  [Melbourne-pm] SOAP::Lite           
                                       Serializing Complex objects.        
                                                                           
             23/01/2006 02:58                                              
             PM                                                            
                                                                           
                                                                           
                                                                           




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
envelope.

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},
type=>'dateTime');
    my $descriptor=SOAP::Data->new(value=>$value->{descriptor},
type=>'ns1:sample_Descriptor');
    my $rval=[$name, {'xsi:type'=>'ns1:sample_SumExpression', %$attr},
{a=>$a, b=>$b, dateAdded=>$dateAdded, descriptor=>$descriptor}];
    return $rval;
}

and

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
xmlns:ns1="http://..."
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
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"
xmlns:tns="http://sampleWebServices.wsdl"><soap:Body><executeExpression
xmlns="sampleServices"><expression
xsi:type="ns1:sample_SumExpression"><descriptor
xsi:type="ns1:sample_Descriptor">HASH(0x9c7d55c)</descriptor><a
xsi:type="xsd:string">900</a><b xsi:type="xsd:string">100</b><dateAdded
xsi:type="xsd:dateTime">2006-01-23T03:32:03.781
Z</dateAdded></expression></executeExpression></soap:Body></soap:Envelope>

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
http://mail.pm.org/mailman/listinfo/melbourne-pm




More information about the Melbourne-pm mailing list