Loading ...
Sorry, an error occurred while loading the content.

Re: parsing request at mod_soap server

Expand Messages
  • sherwln
    [Sorry if it s already a duplicate. My opera suddenly closed and I have no idea if it was already sent]--- In soaplite@y..., Duncan Cameron
    Message 1 of 4 , Jan 27, 2002
    • 0 Attachment
      [Sorry if it's already a duplicate. My opera suddenly closed
      and I have no idea if it was already sent]

      --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
      > This is a very frequently occuring question. Paul answered a similar
      > question a few months ago, look here =>
      > http://groups.yahoo.com/group/soaplite/message/746
      >

      Thanks. I already read that post while I was digging through
      the archive before I asked for help. It just didn't give me
      _enough_ hint to solve my long problem.

      Anyway, your post really helped. I appreciate it.

      > After fiddling around here's what I came up with based on your example.
      > It navigates through the SOM by element position, so that there are no
      > problems with dataof()/valueof(). However, there _must_ be a better way!
      >
      > my $som = SOAP::Deserializer->deserialize($xml);
      > # Iterate through all child elements of PostFile
      > for ($i = 1; my $record = $som->dataof("/PostFile/[$i]"); $i++) {
      > print join(' ', $record->name, $record->attr->{name},
      > $record->attr->{password}), "\n";
      > # Iterate through all child elements of the current Record element
      > for ($j = 1; my $file = $som->dataof("/PostFile/[$i]/[$j]"); $j++) {
      > print join(' ', $file->name, $file->value->{Content},
      > $file->value->{URL}), "\n";
      > }
      > }
      >

      I modified your code a little bit and
      I'm posting it for the newbies like me that
      might come across the same situation. ¦:¬)

      package RSource;

      use strict;
      use vars qw(@ISA);
      @ISA = qw(SOAP::Server::Parameters); # to get envelope

      sub PostFile {
      my $self = shift;
      my $envelope = pop;
      my $header = $envelope->header;

      # Iterate through all child elements of PostFile
      for (my $i = 1; my $record = $envelope->dataof("//PostFile/[$i]"); $i++) =
      {
      print join(' ', $record->name, $record->attr->{name},
      $record->attr->{password}), "\n";

      # Iterate through all child elements of the current Record element
      for (my $j = 1; my $file = $envelope->dataof("//PostFile/[$i]/[$j]"); $=
      j++) {
      print join(' ', $file->name, $file->value->{Content},
      $file->value->{URL}), "\n";
      }
      }

      # Other stuff here
      }

      > Regards,
      > Duncan Cameron
      >
      > On 2002-01-27 sherwln <sherwln@y...> wrote:
      > ><m:PostFile xmlns:m="urn:RSource">
      > > <Record name="first.lastname" password="password">
      > > <File>
      > > <URL>http://webserver/temp/file1</URL>
      > > <Content>text</Content>
      > > </File>
      > > <File>
      > > <URL>http://webserver/temp/file2</URL>
      > > <Content>text</Content>
      > > </File>
      > > </Record>
      > > <Record name="second.lastname" password="password">
      > > <File>
      > > <URL>http://webserver/temp/file3</URL>
      > > <Content>text</Content>
      > > </File>
      > > <File>
      > > <URL>http://webserver/temp/file4</URL>
      > > <Content>text</Content>
      > > </File>
      > > </Record>
      > ></m:PostFile>

      --
      sherwin
    Your message has been successfully submitted and would be delivered to recipients shortly.