views:

351

answers:

0

I am trying to call the web service from Perl with the SOAP:Lite module. The web service has a parameter of complex type that I fail to construct correctly. Here is the relevant portion of wsdl:schema

<complexType name="TagData">
  <sequence>
     <element name="order" type="xsd:int"/>
     <element name="value" type="xsd:string"/>
  </sequence>
</complexType>

<complexType name="ArrayOfTagData">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item" type="TagData"/>
    </sequence>
</complexType>

<complexType name="Topic">
    <sequence>
     <element name="topicName" type="xsd:string"/>
     <element maxOccurs="1" minOccurs="0" name="tagData" type="ArrayOfTagData"/>
    </sequence>
</complexType>

I need to construct parameter of type "Topic" which contains tagData of "ArrayOfTagData" which contains elements of type "TagData". The nested structure and cumbersome SOAP::Data->new syntaxt cause that I fail to generate the envelope with the correct structure and namespacing.

Any help would be appreciated.

Updated: Here is the solution that worked for me:

my @items = ();
my $item  = {};
$item->{'order'} = 0;
$item->{'value'}  = 'java';
my $elem = SOAP::Data->name('item')->value($item)->type('TagData');
push( @items, $elem );

$item            = {};
$item->{'order'} = 1;
$item->{'value'}  = 'perl';
$elem= SOAP::Data->name('item')->value($item)->type('TagData');
push( @items, $elem );

my $tagParam = SOAP::Data->name(
"tagData" => \SOAP::Data->value(
    SOAP::Data->name( 'item' => @items[0] )->type('TagData'),
    SOAP::Data->name( 'item' => @items[1] )->type('TagData'))
    )->type('ArrayOfTagData');

my @soapParam = (
    SOAP::Data->new( name => 'topicName',  value => 'Whatever' ),
    $tagParam
);

#now @soapParam can be passed as parameter to SOAP call