Raf wrote:
> A quick test might be to change warn([EMAIL PROTECTED]) to:
> warn($_[2]->{listItem}->[0]->{attrVal})  and see if you get 'Wert1'?

Thanks for your reply, Ralf.

Finally, I got it to work an hour ago. I try no more to access
the parameters directly but with help of the SOAP::Server object.

Because it took me days of reading, testing and 'googling' I want
to share my solution with the list. Perhaps it'll save somebody's time.

Given the following xml structure of the data to process

<List>
   <ListItem>
      <Name>Name1</Name>
      <Value>Val1</Value>
   </ListItem>
   <ListItem>
      <Name>Name2</Name>
      <Value>Val2</Value>
   </ListItem>
</List>

SOAP::Lite will build the internal representation

$VAR1 = [
          bless( {
                   'ListItem' => [
                                 bless( {
                                          'Name' => 'Name1',
                                          'Value' => 'Val1'
                                        } ),
                                 bless( {
                                          'Name' => 'Name2',
                                          'Value' => 'Val2'
                                        } )
                               ]
                 }, 'List' )
        ];

To access this data structure you can use the 'valueof' method
from the SOAP::SOM class, eg:

use SOAP::Lite;

SOAP::Transport::HTTP::CGI
   -> dispatch_to('MySOAPService')
   -> handle;

BEGIN {

package MySOAPService;

use strict;
use vars qw(@ISA);
@ISA = qw(SOAP::Server::Parameters);

sub ListHandler {
   my $self = shift;
   my $envelope = pop;

   my $i = 0;
   for my $item ($envelope->valueof("//ListHandler/List/ListItem")) {
      $ListItemName = $item->{Name};
      $ListItemValue = $item->{Value};

      # ...
      $i++;
   }

   return SOAP::Data->name("ItemCount" => $i);
}
}

That's all.

Regards

Tobias



Reply via email to