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

Re: [soaplite] Constructing dynamic number of elements with SOAP::Data

Expand Messages
  • Doug Fulton
    Brilliant. Now, after building up my dynamic hash, say %pages = ( a ,1, b ,2, c ,3); I traverse it and push resulting SOAP::Data objects into @values: while
    Message 1 of 5 , Mar 25, 2002
    • 0 Attachment
      Brilliant.

      Now, after building up my dynamic hash, say

      %pages = ("a",1,"b",2,"c",3);

      I traverse it and push resulting SOAP::Data objects into @values:

      while (($key, $value) = each(%pages)) {
      push @values, SOAP::Data->name(page => {url => $key, hits =>
      $value});
      }

      Then I use @values as you indicated.

      my $opt2 = SOAP::Data->name(pages => \SOAP::Data->value(@values));

      It works like a charm. Simple, really. But as they say, before you
      understand something, it seems impossible and once you understand it, it
      seems trivial.

      Thanks much!!
      Doug

      On Monday, March 25, 2002, at 05:37 PM, Paul Kulchenko wrote:

      > Hi, Doug!
      >
      > Something like this should work:
      >
      > use SOAP::Lite;
      >
      > #1
      >
      > my $opt1 = SOAP::Data->name(pages => \SOAP::Data->value(
      > SOAP::Data->name(page => {url => "blah", hits => 81})
      > ));
      >
      > print SOAP::Serializer->maptype({SOAPStruct => ''})->readable(1)
      > ->method(something => $opt1);
      >
      > #2
      >
      > my @values = map { SOAP::Data->name(page => $_) }
      > {url => "blah", hits => 81},
      > {url => "foo", hits => 181};
      >
      > my $opt2 = SOAP::Data->name(pages => \SOAP::Data->value(@values));
      >
      > print SOAP::Serializer->maptype({SOAPStruct => ''})->readable(1)
      > ->method(something => $opt2);
      >
      > Let me know if it doesn't work for you for some reason.
      >
      > Best wishes, Paul.
      >
      > --- Doug Fulton <dfulton@...> wrote:
      >> I am trying to construct the following as part of my request:
      >>
      >> <pages>
      >> <page> <url>blah</url> <hits>88</hits></page>
      >> <page> <url>deeblah</url> <hits>65</hits></page>
      >> ...
      >> </pages>
      >>
      >> I don't know in advance how many page elements I will have. Advice
      >> on
      >> how to do this with SOAP::Data (or otherwise)? My search for
      >> similar
      >> examples has come up empty. soapenv.org has a nice example of
      >> nested
      >> elements, but not in a dynamic context.
      >>
      >> Cheers,
      >> Doug
      >>
      >>
      >>
      >>
      >> ------------------------ Yahoo! Groups Sponsor
      >>
      >> To unsubscribe from this group, send an email to:
      >> soaplite-unsubscribe@yahoogroups.com
      >>
      >>
      >>
      >> Your use of Yahoo! Groups is subject to
      >> http://docs.yahoo.com/info/terms/
      >>
      >>
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Yahoo! Movies - coverage of the 74th Academy AwardsÆ
      > http://movies.yahoo.com/
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.