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

Re: [soaplite] parsing request at mod_soap server

Expand Messages
  • Richard Letts
    ... the fact the question comes up so often indicates that the current behavoir is not what is desired, and we need something to override the behavoir. I d
    Message 1 of 4 , Jan 27, 2002
      On Sun, 27 Jan 2002, Duncan Cameron wrote:

      > Hello sherwln,
      >
      > 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

      the fact the question comes up so often indicates that the current
      behavoir is not what is desired, and we need something to override the
      behavoir. I'd like a setting where I can say 'parse this as a list, and
      not as a hash'. I'd write it myself except the use of map has obfusticated
      the code to the point where I cannot understand what it is trying to do.

      > 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!

      I modified Lite.pm, after about where the comment
      # $name is not used here ....
      ....
      # don't use class/type if anyType/ur-type is speficied

      to say something like:
      # $name is not used here ....
      ....

      $class='foo' if ($name eq '{http://www.illuin.org/Servicea}/foo')
      # don't use class/type if anyType/ur-type is specified

      and adding later on (still in the SOAP::Deserializer Package)

      # I don't know why this works, but it does.
      sub as_foo {
      my $self=shift;
      [ map { scalar(($self->decode_object($_))[1] } &{$_[3] || []} ];
      }
      [[ thanks to Paul for the as_foo code -- but I couldn't figure out the
      proper way to get it invoked]]

      now things of the form
      <foo>
      <bar>one</bar>
      <bar>two</bar>
      <bar>three</bar>
      </foo>

      get deserialized properly.

      I'd tried to figure out how to tell soap::Lite the right information
      about the <foo> tag but given up as being impossible.

      RjL
      +--------------------------+
      | richard@... | ... and the light of the Lamps of the
      +--------------------------+ Valar flowed out over the Earth
    • 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 2 of 4 , Jan 27, 2002
        [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.