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

RE: [soaplite] Re: nested elements in Body...

Expand Messages
  • William McCracken
    John, Here is what I m working on right now. This might help you: The envelope:
    Message 1 of 10 , Feb 13, 2002
    • 0 Attachment
      John,

      Here is what I'm working on right now. This might help you:

      The envelope:

      <SOAP-ENV:Body>
      <namesp1:insert xmlns:namesp1="http://kobe.emc.usi.net/DemoService">
      <devorcs xsi:type="xsd:string">dev_id</devorcs>
      <id xsi:type="xsd:int">123</id>
      <metric>
      <metricname xsi:type="xsd:string">memory</metricname>
      <measurement>
      <field xsi:type="xsd:string">avail</field>
      <value xsi:type="xsd:float">3.5</value>
      </measurement>
      <measurement>
      <field xsi:type="xsd:string">avail</field>
      <value xsi:type="xsd:float">4.5</value>
      </measurement>
      </metric>
      </namesp1:insert>
      </SOAP-ENV:Body>

      I have multiple measurements within each metric.

      The client loads an array of parameters:

      my @parameters = (my @parameters = (
      SOAP::Data->name(devorcs => 'dev_id'),
      SOAP::Data->name(id => 123),
      SOAP::Data->name(metric => (
      \SOAP::Data->value(
      SOAP::Data->name(metricname =>
      'memory'),
      SOAP::Data->name(measurement =>
      \SOAP::Data->value(

      SOAP::Data->name(field => 'avail'),

      SOAP::Data->name(value => '3.5'),
      )
      ),
      \SOAP::Data->value(

      SOAP::Data->name(field => 'avail'),

      SOAP::Data->name(value => '4.5'),
      )
      ),
      )
      )
      )
      );

      Watch those parens ....

      then I run an insert method over soap:

      my $som = $service->insert(@parameters);

      I have some test code written to parse this on the server side, but it isn't
      on a public IP range. Here's my test code that dumps it to a flat file:


      sub insert {
      my $som = pop;
      my ($class, @params) = @_;
      my $metnums = 0;
      my $measnums = 0;

      my $id = $som->valueof('//insert/id');
      my $devorcs = $som->valueof('//insert/devorcs');

      open (TEST,">test");
      print TEST $class, "\n";

      print TEST "id: $id\n";
      print TEST "devorcs: $devorcs\n";

      for (my $k = 1; my $record = $som->dataof("//insert/[$k]"); $k++) {
      if ($record->name eq 'metric') {
      print TEST "metric: ", $record->value->{'metricname'}, "\n";
      $metnums++;
      for (my $j = 1; my $recdata = $som->dataof("//insert/[$k]/[$j]"); $j++) {
      if ($recdata->name eq 'measurement') {
      $measnums++;
      print TEST join(' ', $recdata->name, "\n");
      print TEST "\tfield: ", $recdata->value->{'field'}, "\n";
      print TEST "\tvalue: ", $recdata->value->{'value'}, "\n";
      }
      }
      }
      }


      close(TEST);

      return "Received $metnums metrics and $measnums measurements";
      }


      Hope this helps,

      Will



      >From: "John Powell" <jpowell@...>
      >To: "SOAP Lite Mailing List" <soaplite@yahoogroups.com>
      >Subject: RE: [soaplite] Re: nested elements in Body...
      >Date: Wed, 13 Feb 2002 09:14:26 -0500
      >
      >Byrne&Will,
      >
      >Thank you - this article really helps!!
      >I wonder if you could go one step further and imagine that the getMetric
      >example could handle a list of measurements as in :
      >
      ><SOAP-ENV:Body>
      > <namesp1:getMetric xmlns:namesp1="urn:vgx-foo">
      > <name xsi:type="xsd:string">memory</name>
      > <measurement>
      > <field xsi:type="xsd:string">avail</field>
      > <value xsi:type="xsd:float">1.2</value>
      > </measurement>
      > <measurement>
      > <field xsi:type="xsd:string">avail2</field>
      > <value xsi:type="xsd:float">3.4</value>
      > </measurement>
      > </namesp1:getMetric>
      ></SOAP-ENV:Body>
      >
      >- How would you alter the code?
      >- If it helps, assume that the measurements are in an array of hashes (that
      >could have more than two entries)
      >I've been trying to figure this one out for a while - anyone?
      >Does anyone know of a server requiring this kind of input that I can try it
      >on? I have one, but its too complex to use as a good test bed and I'm
      >unable
      >to make it public at this time.
      >
      >John
      >BTW, The closing tag in your article was getHoroscope rather than getMetric
      >for this example.
      >
      > -----Original Message-----
      > From: Byrne Reese [mailto:breese@...]
      > Sent: Tuesday, February 12, 2002 3:53 PM
      > To: William McCracken
      > Cc: SOAP Lite Mailing List
      > Subject: [soaplite] Re: nested elements in Body...
      >
      >
      > Will - thanks for the question... I threw together a little tutoral you
      > might be interested in... I incorporated your question into it! I hope
      > it helps...
      >
      > http://soapenv.org/article.pl?sid=02/02/11/1740229
      >
      > On Tue, 2002-02-12 at 11:28, William McCracken wrote:
      > >
      > > Byrne,
      > >
      > > I actually was just using that as an example.
      > >
      > > I am trying to create the following structure:
      > >
      > > <metric>
      > > <name>memory</name>
      > > <measurement>
      > > <field>avail</field>
      > > <value>1.2</field>
      > > </measurement>
      > > </metric>
      > >
      > > -Will
      > >
      > > >From: Byrne Reese <breese@...>
      > > >To: usiwill <usiwill@...>
      > > >Subject: Re: nested elements in Body...
      > > >Date: 12 Feb 2002 11:24:10 -0800
      > > >
      > > >Before I answer, let me see if I understand...
      > > >
      > > >Do you want to replicate this SOAP Body *exactly*, or are you trying
      >to
      > > >get horoscopes (hypothetically) for multiple sign like so (which may
      > > >make more sense):
      > > >
      > > > > <getHoroscope>
      > > > > <astrology>
      > > > > <sign xsi:type="xsd:string">libra</sign>
      > > > > <sign xsi:type="xsd:string">aries</sign>
      > > > > </astrology>
      > > > > </getHoroscope>
      > > >
      > > >On Tue, 2002-02-12 at 10:47, usiwill wrote:
      > > > > How would you create the following structure using this method?
      > > > >
      > > > > <getHoroscope>
      > > > > <astrology>
      > > > > <sign xsi:type="xsd:string">libra</sign>
      > > > > <othersign xsi:type="xsd:string">aries</othersign>
      > > > > </astrology>
      > > > > </getHoroscope>
      > > > >
      > > > > I have a need to have multiple nested elements for a project I am
      > > > > working on.
      > > > >
      > > > > Thanks,
      > > > >
      > > > > Will
      > > > >
      > > > >
      > > > >
      > > > > --- In soaplite@y..., Byrne Reese <breese@g...> wrote:
      > > > > > That's the one! Excellent. Maybe I don't know Perl as well as I
      > > >should,
      > > > > > but this would be a great sample to add to the SOAP::Lite
      >cookbook
      >or
      > > > > > FAQ.
      > > > > >
      > > > > > On Mon, 2002-02-11 at 13:28, Taras Shkvarchuk wrote:
      > > > > > > When constructing the body use references instead
      > > > > > > my $body=SOAP::Data->name("getHoroscope" =>
      > > > > > >
      >\SOAP::Data->name("astrology"=>\SOAP::Data->name("sign"=>"libra")));
      > > > > > >
      > > > > > > this gives you:
      > > > > > > <SOAP-ENV:Body>
      > > > > > > <getHoroscope>
      > > > > > > <astrology>
      > > > > > > <sign xsi:type="xsd:string">libra</sign>
      > > > > > > </astrology>
      > > > > > > </getHoroscope>
      > > > > > > </SOAP-ENV:Body>
      > > > > > >
      > > > > > > > -----Original Message-----
      > > > > > > > From: Byrne Reese
      > > > > > > > Sent: Monday, February 11, 2002 1:10 PM
      > > > > > > > To: Duncan Cameron
      > > > > > > > Cc: SOAP Lite Mailing List
      > > > > > > > Subject: Re: [soaplite] nested elements in Body...
      > > > > > > >
      > > > > > > >
      > > > > > > > That did work a little better, however, as a user I grow
      > > > > > > > concerned when
      > > > > > > > I see things serialized in ways different than the example I
      > > > > > > > see posted
      > > > > > > > on a Web services HTML page.
      > > > > > > >
      > > > > > > > For example,
      > > > > > > > $body = { "astrology" => { 'sign' => $SIGN } };
      > > > > > > >
      > > > > > > > $soap = SOAP::Lite
      > > > > > > > ->uri('urn:vgx-horoscope')
      > > > > > > > ->on_action(sub { sprintf "%s",'urn:vgx-horoscope' })
      > > > > > > > ->proxy("$URL")
      > > > > > > > ->getHoroscope($body);
      > > > > > > >
      > > > > > > > Gets serialized into:
      > > > > > > >
      > > > > > > > <SOAP-ENV:Envelope
      > > > > > > > xmlns:namesp2="http://xml.apache.org/xml-soap"
      > > > > > > >
      >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encodi
      > > > > > > > ng/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > > > > > > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > > > > > > > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > > > > > > > xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      > > > > > > > <SOAP-ENV:Body>
      > > > > > > > <namesp1:getHoroscope xmlns:namesp1="urn:vgx-horoscope">
      > > > > > > > <c-gensym3 xsi:type="namesp2:SOAPStruct">
      > > > > > > > <astrology xsi:type="namesp2:SOAPStruct">
      > > > > > > > <sign xsi:type="xsd:string">aries</sign>
      > > > > > > > </astrology>
      > > > > > > > </c-gensym3>
      > > > > > > > </namesp1:getHoroscope>
      > > > > > > > </SOAP-ENV:Body>
      > > > > > > > </SOAP-ENV:Envelope>
      > > > > > > >
      > > > > > > > I just want to get rid of "c-gensyn3" - unless of course
      >this
      >is
      > > > > just
      > > > > > > > SOAP serializing the data and I can be assured that it will
      >be
      > > > > > > > deserialized properly...
      > > > > > > >
      > > > > > > > I agree the 'astrology' element is useless, but it is what
      >the
      > > > > service
      > > > > > > > calls for. :(
      > > > > > > >
      > > > > > > >
      > > > > > > >
      > > > > > > > On Mon, 2002-02-11 at 12:56, Duncan Cameron wrote:
      > > > > > > > > On 2002-02-11 Byrne Reese wrote:
      > > > > > > > > >There *must* be a way to do this more intuitively...
      > > > > > > > > >
      > > > > > > > > >I want to create a simple SOAP::Data struct which will
      > > > > > > > serialize into
      > > > > > > > > >this:
      > > > > > > > > >
      > > > > > > > > ><getHoroscope>
      > > > > > > > > > <astrology>
      > > > > > > > > > <sign>foo</sign>
      > > > > > > > > > </astrology>
      > > > > > > > > ></getHoroscope>
      > > > > > > > > >
      > > > > > > > > >Here is my code:
      > > > > > > > > >
      > > > > > > > > >$body = SOAP::Data->name('astrology' =>
      > > > > > > > SOAP::Data->name('sign' => $SIGN)
      > > > > > > > > > ->type('string')
      >);
      > > > > > > > > This *seems* more intuitive:
      > > > > > > > >
      > > > > > > > > my $body = {'astrology' => {'sign' => 'aries'} };
      > > > > > > > >
      > > > > > > > > >It makes sense to me that if SOAP::Lite will properly
      > > > > > > > serialize perl
      > > > > > > > > >arrays and hashes, it should serialize nested scalars.
      > > > > > > > > >
      > > > > > > > > I think that the docs need to be clearer about exactly
      > > > > > > > where a SOAP::Data
      > > > > > > > > object can go. For example, is it valid to nest them as
      >you
      > > > > > > > have tried?
      > > > > > > > > In your case the first one ('astrology') is unnecessary as
      > > > > > > > it doesn't add
      > > > > > > > > anything.
      > > > > > > > >
      > > > > > > > > Regards,
      > > > > > > > > Duncan Cameron
      > > > > > > > >
      > > > > > > > --
      > > > > > > > :/ byrne
      > > > > > > >
      > > > > > > > breese@g...
      > > > > > > > (415) 544-7732
      > > > > > > >
      > > > > > > > ------------------------ Yahoo! Groups Sponsor
      > > > > > > > ---------------------~-->
      > > > > > > > Sponsored by VeriSign - The Value of Trust
      > > > > > > > When building an e-commerce site, you want to start with a
      > > > > > > > secure foundation. Learn how with VeriSign's FREE Guide.
      > > > > > > > http://us.click.yahoo.com/kWSNbC/XdiDAA/yigFAA/W6uqlB/TM
      > > > > > > >
      >--------------------------------------------------------------
      > > > > > > > -------~->
      > > > > > > >
      > > > > > > > To unsubscribe from this group, send an email to:
      > > > > > > > soaplite-unsubscribe@y...
      > > > > > > >
      > > > > > > >
      > > > > > > >
      > > > > > > > Your use of Yahoo! Groups is subject to
      > > > > > > http://docs.yahoo.com/info/terms/
      > > > > > --
      > > > > > :/ byrne
      > > > > >
      > > > > > breese@g...
      > > > > > (415) 544-7732
      > > > >
      > > >--
      > > >:/ byrne
      > > >
      > > >breese@...
      > > >(415) 544-7732
      > >
      > >
      > >
      > >
      > > _________________________________________________________________
      > > MSN Photos is the easiest way to share and print your photos:
      > > http://photos.msn.com/support/worldwide.aspx
      > >
      > --
      > :/ byrne
      >
      > breese@...
      > (415) 544-7732
      >
      > Yahoo! Groups Sponsor
      > ADVERTISEMENT
      >
      >
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      >




      _________________________________________________________________
      Send and receive Hotmail on your mobile device: http://mobile.msn.com
    • John Powell
      Will, Its starting to look a little too easy, but yes those parens can be tricky. My next step is making this work with an arbitrary size array (ie number of
      Message 2 of 10 , Feb 14, 2002
      • 0 Attachment
        Will,
        Its starting to look a little too easy, but yes those parens can be tricky. My next step is making this work with an arbitrary size array (ie number of measurements).
        Thanks again.
        John
        -----Original Message-----
        From: William McCracken [mailto:usiwill@...]
        Sent: Wednesday, February 13, 2002 11:17 AM
        To: jpowell@...; soaplite@yahoogroups.com
        Subject: RE: [soaplite] Re: nested elements in Body...

        John,

        Here is what I'm working on right now. This might help you:

        The envelope:

        <SOAP-ENV:Body>
        <namesp1:insert xmlns:namesp1="http://kobe.emc.usi.net/DemoService">
          <devorcs xsi:type="xsd:string">dev_id</devorcs>
          <id xsi:type="xsd:int">123</id>
          <metric>
            <metricname xsi:type="xsd:string">memory</metricname>
            <measurement>
              <field xsi:type="xsd:string">avail</field>
              <value xsi:type="xsd:float">3.5</value>
            </measurement>
            <measurement>
              <field xsi:type="xsd:string">avail</field>
              <value xsi:type="xsd:float">4.5</value>
            </measurement>
          </metric>
        </namesp1:insert>
        </SOAP-ENV:Body>

        I have multiple measurements within each metric.

        The client loads an array of parameters:

        my @parameters = (my @parameters = (
                SOAP::Data->name(devorcs => 'dev_id'),
                SOAP::Data->name(id      => 123),
                SOAP::Data->name(metric  => (
                                                \SOAP::Data->value(
                                                SOAP::Data->name(metricname =>
        'memory'),
                                                SOAP::Data->name(measurement =>
        \SOAP::Data->value(
                                                                                 
        SOAP::Data->name(field => 'avail'),
                                                                                 
        SOAP::Data->name(value => '3.5'),
                                                                                 )
                                                                 ),
        \SOAP::Data->value(
                                                                                 
        SOAP::Data->name(field => 'avail'),
                                                                                 
        SOAP::Data->name(value => '4.5'),
                                                                                 )
                                                                 ),
                                                )
                                            )
                                )
        );

        Watch those parens ....

        then I run an insert method over soap:

        my $som =  $service->insert(@parameters);

        I have some test code written to parse this on the server side, but it isn't
        on a public IP range. Here's my test code that dumps it to a flat file:


        sub insert {
              my $som = pop;
              my ($class, @params) = @_;
              my $metnums = 0;
              my $measnums = 0;

              my $id = $som->valueof('//insert/id');
              my $devorcs = $som->valueof('//insert/devorcs');

                  open (TEST,">test");
                  print TEST $class, "\n";

              print TEST "id: $id\n";
              print TEST "devorcs: $devorcs\n";

              for (my $k = 1; my $record = $som->dataof("//insert/[$k]"); $k++) {
                    if ($record->name eq 'metric') {
                          print TEST "metric: ", $record->value->{'metricname'}, "\n";
                          $metnums++;
                          for (my $j = 1; my $recdata = $som->dataof("//insert/[$k]/[$j]"); $j++) {
                                if ($recdata->name eq 'measurement') {
                                      $measnums++;
                                      print TEST join(' ', $recdata->name, "\n");
                                      print TEST "\tfield: ", $recdata->value->{'field'}, "\n";
                                      print TEST "\tvalue: ", $recdata->value->{'value'}, "\n";
                                }
                          }
                    }
              }


                  close(TEST);

            return "Received $metnums metrics and $measnums measurements";
          }


        Hope this helps,

        Will



        >From: "John Powell" <jpowell@...>
        >To: "SOAP Lite Mailing List" <soaplite@yahoogroups.com>
        >Subject: RE: [soaplite] Re: nested elements in Body...
        >Date: Wed, 13 Feb 2002 09:14:26 -0500
        >
        >Byrne&Will,
        >
        >Thank you - this article really helps!!
        >I wonder if you could go one step further and imagine that the getMetric
        >example could handle a list of  measurements as in :
        >
        ><SOAP-ENV:Body>
        >    <namesp1:getMetric xmlns:namesp1="urn:vgx-foo">
        >       <name xsi:type="xsd:string">memory</name>
        >       <measurement>
        >          <field xsi:type="xsd:string">avail</field>
        >          <value xsi:type="xsd:float">1.2</value>
        >       </measurement>
        >       <measurement>
        >          <field xsi:type="xsd:string">avail2</field>
        >          <value xsi:type="xsd:float">3.4</value>
        >       </measurement>
        >    </namesp1:getMetric>
        ></SOAP-ENV:Body>
        >
        >- How would you alter the code?
        >- If it helps, assume that the measurements are in an array of hashes (that
        >could have more than two entries)
        >I've been trying to figure this one out for a while - anyone?
        >Does anyone know of a server requiring this kind of input that I can try it
        >on? I have one, but its too complex to use as a good test bed and I'm
        >unable
        >to make it public at this time.
        >
        >John
        >BTW, The closing tag in your article was getHoroscope rather than getMetric
        >for this example.
        >
        >   -----Original Message-----
        >   From: Byrne Reese [mailto:breese@...]
        >   Sent: Tuesday, February 12, 2002 3:53 PM
        >   To: William McCracken
        >   Cc: SOAP Lite Mailing List
        >   Subject: [soaplite] Re: nested elements in Body...
        >
        >
        >   Will - thanks for the question... I threw together a little tutoral you
        >   might be interested in... I incorporated your question into it! I hope
        >   it helps...
        >
        >   http://soapenv.org/article.pl?sid=02/02/11/1740229
        >
        >   On Tue, 2002-02-12 at 11:28, William McCracken wrote:
        >   >
        >   > Byrne,
        >   >
        >   > I actually was just using that as an example.
        >   >
        >   > I am trying to create the following structure:
        >   >
        >   > <metric>
        >   >     <name>memory</name>
        >   >     <measurement>
        >   >         <field>avail</field>
        >   >         <value>1.2</field>
        >   >     </measurement>
        >   > </metric>
        >   >
        >   > -Will
        >   >
        >   > >From: Byrne Reese <breese@...>
        >   > >To: usiwill <usiwill@...>
        >   > >Subject: Re: nested elements in Body...
        >   > >Date: 12 Feb 2002 11:24:10 -0800
        >   > >
        >   > >Before I answer, let me see if I understand...
        >   > >
        >   > >Do you want to replicate this SOAP Body *exactly*, or are you trying
        >to
        >   > >get horoscopes (hypothetically) for multiple sign like so (which may
        >   > >make more sense):
        >   > >
        >   > > > <getHoroscope>
        >   > > >         <astrology>
        >   > > >            <sign xsi:type="xsd:string">libra</sign>
        >   > > >            <sign xsi:type="xsd:string">aries</sign>
        >   > > >        </astrology>
        >   > > > </getHoroscope>
        >   > >
        >   > >On Tue, 2002-02-12 at 10:47, usiwill wrote:
        >   > > > How would you create the following structure using this method?
        >   > > >
        >   > > > <getHoroscope>
        >   > > >         <astrology>
        >   > > >            <sign xsi:type="xsd:string">libra</sign>
        >   > > >            <othersign xsi:type="xsd:string">aries</othersign>
        >   > > >        </astrology>
        >   > > > </getHoroscope>
        >   > > >
        >   > > > I have a need to have multiple nested elements for a project I am
        >   > > > working on.
        >   > > >
        >   > > > Thanks,
        >   > > >
        >   > > > Will
        >   > > >
        >   > > >
        >   > > >
        >   > > > --- In soaplite@y..., Byrne Reese <breese@g...> wrote:
        >   > > > > That's the one! Excellent. Maybe I don't know Perl as well as I
        >   > >should,
        >   > > > > but this would be a great sample to add to the SOAP::Lite
        >cookbook
        >or
        >   > > > > FAQ.
        >   > > > >
        >   > > > > On Mon, 2002-02-11 at 13:28, Taras Shkvarchuk wrote:
        >   > > > > > When constructing the body use references instead
        >   > > > > > my $body=SOAP::Data->name("getHoroscope" =>
        >   > > > > >
        >\SOAP::Data->name("astrology"=>\SOAP::Data->name("sign"=>"libra")));
        >   > > > > >
        >   > > > > > this gives you:
        >   > > > > >   <SOAP-ENV:Body>
        >   > > > > >     <getHoroscope>
        >   > > > > >       <astrology>
        >   > > > > >         <sign xsi:type="xsd:string">libra</sign>
        >   > > > > >       </astrology>
        >   > > > > >     </getHoroscope>
        >   > > > > >   </SOAP-ENV:Body>
        >   > > > > >
        >   > > > > > > -----Original Message-----
        >   > > > > > > From: Byrne Reese
        >   > > > > > > Sent: Monday, February 11, 2002 1:10 PM
        >   > > > > > > To: Duncan Cameron
        >   > > > > > > Cc: SOAP Lite Mailing List
        >   > > > > > > Subject: Re: [soaplite] nested elements in Body...
        >   > > > > > >
        >   > > > > > >
        >   > > > > > > That did work a little better, however, as a user I grow
        >   > > > > > > concerned when
        >   > > > > > > I see things serialized in ways different than the example I
        >   > > > > > > see posted
        >   > > > > > > on a Web services HTML page.
        >   > > > > > >
        >   > > > > > > For example,
        >   > > > > > > $body = { "astrology" => { 'sign' => $SIGN } };
        >   > > > > > >
        >   > > > > > > $soap = SOAP::Lite
        >   > > > > > >   ->uri('urn:vgx-horoscope')
        >   > > > > > >   ->on_action(sub { sprintf "%s",'urn:vgx-horoscope' })
        >   > > > > > >   ->proxy("$URL")
        >   > > > > > >   ->getHoroscope($body);
        >   > > > > > >
        >   > > > > > > Gets serialized into:
        >   > > > > > >
        >   > > > > > > <SOAP-ENV:Envelope
        >   > > > > > > xmlns:namesp2="http://xml.apache.org/xml-soap"
        >   > > > > > >
        >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encodi
        >   > > > > > > ng/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        >   > > > > > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        >   > > > > > > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        >   > > > > > > xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        >   > > > > > >   <SOAP-ENV:Body>
        >   > > > > > >     <namesp1:getHoroscope xmlns:namesp1="urn:vgx-horoscope">
        >   > > > > > >       <c-gensym3 xsi:type="namesp2:SOAPStruct">
        >   > > > > > >         <astrology xsi:type="namesp2:SOAPStruct">
        >   > > > > > >           <sign xsi:type="xsd:string">aries</sign>
        >   > > > > > >         </astrology>
        >   > > > > > >       </c-gensym3>
        >   > > > > > >     </namesp1:getHoroscope>
        >   > > > > > >   </SOAP-ENV:Body>
        >   > > > > > > </SOAP-ENV:Envelope>
        >   > > > > > >
        >   > > > > > > I just want to get rid of "c-gensyn3" - unless of course
        >this
        >is
        >   > > > just
        >   > > > > > > SOAP serializing the data and I can be assured that it will
        >be
        >   > > > > > > deserialized properly...
        >   > > > > > >
        >   > > > > > > I agree the 'astrology' element is useless, but it is what
        >the
        >   > > > service
        >   > > > > > > calls for. :(
        >   > > > > > >
        >   > > > > > >
        >   > > > > > >
        >   > > > > > > On Mon, 2002-02-11 at 12:56, Duncan Cameron wrote:
        >   > > > > > > > On 2002-02-11 Byrne Reese wrote:
        >   > > > > > > > >There *must* be a way to do this more intuitively...
        >   > > > > > > > >
        >   > > > > > > > >I want to create a simple SOAP::Data struct which will
        >   > > > > > > serialize into
        >   > > > > > > > >this:
        >   > > > > > > > >
        >   > > > > > > > ><getHoroscope>
        >   > > > > > > > >   <astrology>
        >   > > > > > > > >      <sign>foo</sign>
        >   > > > > > > > >   </astrology>
        >   > > > > > > > ></getHoroscope>
        >   > > > > > > > >
        >   > > > > > > > >Here is my code:
        >   > > > > > > > >
        >   > > > > > > > >$body = SOAP::Data->name('astrology' =>
        >   > > > > > > SOAP::Data->name('sign' => $SIGN)
        >   > > > > > > > >                                        ->type('string')
        >);
        >   > > > > > > > This *seems* more intuitive:
        >   > > > > > > >
        >   > > > > > > > my $body = {'astrology' => {'sign' => 'aries'} };
        >   > > > > > > >
        >   > > > > > > > >It makes sense to me that if SOAP::Lite will properly
        >   > > > > > > serialize perl
        >   > > > > > > > >arrays and hashes, it should serialize nested scalars.
        >   > > > > > > > >
        >   > > > > > > > I think that the docs need to be clearer about exactly
        >   > > > > > > where a SOAP::Data
        >   > > > > > > > object can go. For example, is it valid to nest them as
        >you
        >   > > > > > > have tried?
        >   > > > > > > > In your case the first one ('astrology') is unnecessary as
        >   > > > > > > it doesn't add
        >   > > > > > > > anything.
        >   > > > > > > >
        >   > > > > > > > Regards,
        >   > > > > > > > Duncan Cameron
        >   > > > > > > >
        >   > > > > > > --
        >   > > > > > > :/ byrne
        >   > > > > > >
        >   > > > > > > breese@g...
        >   > > > > > > (415) 544-7732
        >   > > > > > >
        >   > > > > > > ------------------------ Yahoo! Groups Sponsor
        >   > > > > > > ---------------------~-->
        >   > > > > > > Sponsored by VeriSign - The Value of Trust
        >   > > > > > > When building an e-commerce site, you want to start with a
        >   > > > > > > secure foundation. Learn how with VeriSign's FREE Guide.
        >   > > > > > > http://us.click.yahoo.com/kWSNbC/XdiDAA/yigFAA/W6uqlB/TM
        >   > > > > > >
        >--------------------------------------------------------------
        >   > > > > > > -------~->
        >   > > > > > >
        >   > > > > > > To unsubscribe from this group, send an email to:
        >   > > > > > > soaplite-unsubscribe@y...
        >   > > > > > >
        >   > > > > > >
        >   > > > > > >
        >   > > > > > > Your use of Yahoo! Groups is subject to
        >   > > > > > http://docs.yahoo.com/info/terms/
        >   > > > > --
        >   > > > > :/ byrne
        >   > > > >
        >   > > > > breese@g...
        >   > > > > (415) 544-7732
        >   > > >
        >   > >--
        >   > >:/ byrne
        >   > >
        >   > >breese@...
        >   > >(415) 544-7732
        >   >
        >   >
        >   >
        >   >
        >   > _________________________________________________________________
        >   > MSN Photos is the easiest way to share and print your photos:
        >   > http://photos.msn.com/support/worldwide.aspx
        >   >
        >   --
        >   :/ byrne
        >
        >   breese@...
        >   (415) 544-7732
        >
        >         Yahoo! Groups Sponsor
        >               ADVERTISEMENT
        >
        >
        >
        >
        >   To unsubscribe from this group, send an email to:
        >   soaplite-unsubscribe@yahoogroups.com
        >
        >
        >
        >   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >




        _________________________________________________________________
        Send and receive Hotmail on your mobile device: http://mobile.msn.com



        To unsubscribe from this group, send an email to:
        soaplite-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      • John Powell
        All, With some help from Will (Thanks Will!), I have figured out what I need; maybe there s a more elegant way to do this, but the following allows me to
        Message 3 of 10 , Feb 18, 2002
        • 0 Attachment
          All,
           
          With some help from Will (Thanks Will!), I have figured out what I need; maybe there's a more elegant way to do this, but the following allows me to output an arbitrary sized array of complex structures. Using his example, the size of the array is given by the the measurements array:
          Commentary: Has anyone given any thought to a standard way to indent and line up parens to make it easier to read? What do you think about the way I've handled this?
           
          John 
           
          use SOAP::Lite;
           
          my @measurements = (5.6, 6.7);
           
          my @parameters =
          (
              SOAP::Data->name(devorcs => 'dev_id'),
              SOAP::Data->name(id      => 123),
              SOAP::Data->name
              (
                metric  =>
                (
                      \SOAP::Data->value
                  (
                          SOAP::Data->name(metricname => 'memory'),
                          stuffMeasurements(@measurements)
                  )
               )
            )
          );
           
          sub stuffMeasurements #stuff measurements into SOAP::Data
          {
            my @soaparray;
            for ($i = 0; $i < @_ ; $i++)
            {
           
            @soaparray[i] = SOAP::Data->name(measurement =>
              \SOAP::Data->value(
               SOAP::Data->name(field => 'avail'),                                                                      
                  SOAP::Data->name(value => $_[$i])
                                            )
                                                                 );
            }
           
           my @res = @soaparray;
          }
           
          my $s = SOAP::Lite
                 -> uri('http://ara.com/asdest.wsdl')
                 -> proxy('http://ara.com/asdest.wsdl')
                 -> on_debug(sub{print@_})
                 -> do(@parameters);
           
           -----Original Message-----
          From: John Powell [mailto:jpowell@...]
          Sent: Thursday, February 14, 2002 1:24 PM
          To: William McCracken; soaplite@yahoogroups.com
          Subject: RE: [soaplite] Re: nested elements in Body...

          Will,
          Its starting to look a little too easy, but yes those parens can be tricky. My next step is making this work with an arbitrary size array (ie number of measurements).
          Thanks again.
          John
          -----Original Message-----
          From: William McCracken [mailto:usiwill@...]
          Sent: Wednesday, February 13, 2002 11:17 AM
          To: jpowell@...; soaplite@yahoogroups.com
          Subject: RE: [soaplite] Re: nested elements in Body...

          John,

          Here is what I'm working on right now. This might help you:

          The envelope:

          <SOAP-ENV:Body>
          <namesp1:insert xmlns:namesp1="http://kobe.emc.usi.net/DemoService">
            <devorcs xsi:type="xsd:string">dev_id</devorcs>
            <id xsi:type="xsd:int">123</id>
            <metric>
              <metricname xsi:type="xsd:string">memory</metricname>
              <measurement>
                <field xsi:type="xsd:string">avail</field>
                <value xsi:type="xsd:float">3.5</value>
              </measurement>
              <measurement>
                <field xsi:type="xsd:string">avail</field>
                <value xsi:type="xsd:float">4.5</value>
              </measurement>
            </metric>
          </namesp1:insert>
          </SOAP-ENV:Body>

          I have multiple measurements within each metric.

          The client loads an array of parameters:

          my @parameters = (my @parameters = (
                  SOAP::Data->name(devorcs => 'dev_id'),
                  SOAP::Data->name(id      => 123),
                  SOAP::Data->name(metric  => (
                                                  \SOAP::Data->value(
                                                  SOAP::Data->name(metricname =>
          'memory'),
                                                  SOAP::Data->name(measurement =>
          \SOAP::Data->value(
                                                                                   
          SOAP::Data->name(field => 'avail'),
                                                                                   
          SOAP::Data->name(value => '3.5'),
                                                                                   )
                                                                   ),
          \SOAP::Data->value(
                                                                                   
          SOAP::Data->name(field => 'avail'),
                                                                                   
          SOAP::Data->name(value => '4.5'),
                                                                                   )
                                                                   ),
                                                  )
                                              )
                                  )
          );

          Watch those parens ....

          then I run an insert method over soap:

          my $som =  $service->insert(@parameters);

          I have some test code written to parse this on the server side, but it isn't
          on a public IP range. Here's my test code that dumps it to a flat file:


          sub insert {
                my $som = pop;
                my ($class, @params) = @_;
                my $metnums = 0;
                my $measnums = 0;

                my $id = $som->valueof('//insert/id');
                my $devorcs = $som->valueof('//insert/devorcs');

                    open (TEST,">test");
                    print TEST $class, "\n";

                print TEST "id: $id\n";
                print TEST "devorcs: $devorcs\n";

                for (my $k = 1; my $record = $som->dataof("//insert/[$k]"); $k++) {
                      if ($record->name eq 'metric') {
                            print TEST "metric: ", $record->value->{'metricname'}, "\n";
                            $metnums++;
                            for (my $j = 1; my $recdata = $som->dataof("//insert/[$k]/[$j]"); $j++) {
                                  if ($recdata->name eq 'measurement') {
                                        $measnums++;
                                        print TEST join(' ', $recdata->name, "\n");
                                        print TEST "\tfield: ", $recdata->value->{'field'}, "\n";
                                        print TEST "\tvalue: ", $recdata->value->{'value'}, "\n";
                                  }
                            }
                      }
                }


                    close(TEST);

              return "Received $metnums metrics and $measnums measurements";
            }


          Hope this helps,

          Will



          >From: "John Powell" <jpowell@...>
          >To: "SOAP Lite Mailing List" <soaplite@yahoogroups.com>
          >Subject: RE: [soaplite] Re: nested elements in Body...
          >Date: Wed, 13 Feb 2002 09:14:26 -0500
          >
          >Byrne&Will,
          >
          >Thank you - this article really helps!!
          >I wonder if you could go one step further and imagine that the getMetric
          >example could handle a list of  measurements as in :
          >
          ><SOAP-ENV:Body>
          >    <namesp1:getMetric xmlns:namesp1="urn:vgx-foo">
          >       <name xsi:type="xsd:string">memory</name>
          >       <measurement>
          >          <field xsi:type="xsd:string">avail</field>
          >          <value xsi:type="xsd:float">1.2</value>
          >       </measurement>
          >       <measurement>
          >          <field xsi:type="xsd:string">avail2</field>
          >          <value xsi:type="xsd:float">3.4</value>
          >       </measurement>
          >    </namesp1:getMetric>
          ></SOAP-ENV:Body>
          >
          >- How would you alter the code?
          >- If it helps, assume that the measurements are in an array of hashes (that
          >could have more than two entries)
          >I've been trying to figure this one out for a while - anyone?
          >Does anyone know of a server requiring this kind of input that I can try it
          >on? I have one, but its too complex to use as a good test bed and I'm
          >unable
          >to make it public at this time.
          >
          >John
          >BTW, The closing tag in your article was getHoroscope rather than getMetric
          >for this example.
          >
          >   -----Original Message-----
          >   From: Byrne Reese [mailto:breese@...]
          >   Sent: Tuesday, February 12, 2002 3:53 PM
          >   To: William McCracken
          >   Cc: SOAP Lite Mailing List
          >   Subject: [soaplite] Re: nested elements in Body...
          >
          >
          >   Will - thanks for the question... I threw together a little tutoral you
          >   might be interested in... I incorporated your question into it! I hope
          >   it helps...
          >
          >   http://soapenv.org/article.pl?sid=02/02/11/1740229
          >
          >   On Tue, 2002-02-12 at 11:28, William McCracken wrote:
          >   >
          >   > Byrne,
          >   >
          >   > I actually was just using that as an example.
          >   >
          >   > I am trying to create the following structure:
          >   >
          >   > <metric>
          >   >     <name>memory</name>
          >   >     <measurement>
          >   >         <field>avail</field>
          >   >         <value>1.2</field>
          >   >     </measurement>
          >   > </metric>
          >   >
          >   > -Will
          >   >
          >   > >From: Byrne Reese <breese@...>
          >   > >To: usiwill <usiwill@...>
          >   > >Subject: Re: nested elements in Body...
          >   > >Date: 12 Feb 2002 11:24:10 -0800
          >   > >
          >   > >Before I answer, let me see if I understand...
          >   > >
          >   > >Do you want to replicate this SOAP Body *exactly*, or are you trying
          >to
          >   > >get horoscopes (hypothetically) for multiple sign like so (which may
          >   > >make more sense):
          >   > >
          >   > > > <getHoroscope>
          >   > > >         <astrology>
          >   > > >            <sign xsi:type="xsd:string">libra</sign>
          >   > > >            <sign xsi:type="xsd:string">aries</sign>
          >   > > >        </astrology>
          >   > > > </getHoroscope>
          >   > >
          >   > >On Tue, 2002-02-12 at 10:47, usiwill wrote:
          >   > > > How would you create the following structure using this method?
          >   > > >
          >   > > > <getHoroscope>
          >   > > >         <astrology>
          >   > > >            <sign xsi:type="xsd:string">libra</sign>
          >   > > >            <othersign xsi:type="xsd:string">aries</othersign>
          >   > > >        </astrology>
          >   > > > </getHoroscope>
          >   > > >
          >   > > > I have a need to have multiple nested elements for a project I am
          >   > > > working on.
          >   > > >
          >   > > > Thanks,
          >   > > >
          >   > > > Will
          >   > > >
          >   > > >
          >   > > >
          >   > > > --- In soaplite@y..., Byrne Reese <breese@g...> wrote:
          >   > > > > That's the one! Excellent. Maybe I don't know Perl as well as I
          >   > >should,
          >   > > > > but this would be a great sample to add to the SOAP::Lite
          >cookbook
          >or
          >   > > > > FAQ.
          >   > > > >
          >   > > > > On Mon, 2002-02-11 at 13:28, Taras Shkvarchuk wrote:
          >   > > > > > When constructing the body use references instead
          >   > > > > > my $body=SOAP::Data->name("getHoroscope" =>
          >   > > > > >
          >\SOAP::Data->name("astrology"=>\SOAP::Data->name("sign"=>"libra")));
          >   > > > > >
          >   > > > > > this gives you:
          >   > > > > >   <SOAP-ENV:Body>
          >   > > > > >     <getHoroscope>
          >   > > > > >       <astrology>
          >   > > > > >         <sign xsi:type="xsd:string">libra</sign>
          >   > > > > >       </astrology>
          >   > > > > >     </getHoroscope>
          >   > > > > >   </SOAP-ENV:Body>
          >   > > > > >
          >   > > > > > > -----Original Message-----
          >   > > > > > > From: Byrne Reese
          >   > > > > > > Sent: Monday, February 11, 2002 1:10 PM
          >   > > > > > > To: Duncan Cameron
          >   > > > > > > Cc: SOAP Lite Mailing List
          >   > > > > > > Subject: Re: [soaplite] nested elements in Body...
          >   > > > > > >
          >   > > > > > >
          >   > > > > > > That did work a little better, however, as a user I grow
          >   > > > > > > concerned when
          >   > > > > > > I see things serialized in ways different than the example I
          >   > > > > > > see posted
          >   > > > > > > on a Web services HTML page.
          >   > > > > > >
          >   > > > > > > For example,
          >   > > > > > > $body = { "astrology" => { 'sign' => $SIGN } };
          >   > > > > > >
          >   > > > > > > $soap = SOAP::Lite
          >   > > > > > >   ->uri('urn:vgx-horoscope')
          >   > > > > > >   ->on_action(sub { sprintf "%s",'urn:vgx-horoscope' })
          >   > > > > > >   ->proxy("$URL")
          >   > > > > > >   ->getHoroscope($body);
          >   > > > > > >
          >   > > > > > > Gets serialized into:
          >   > > > > > >
          >   > > > > > > <SOAP-ENV:Envelope
          >   > > > > > > xmlns:namesp2="http://xml.apache.org/xml-soap"
          >   > > > > > >
          >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encodi
          >   > > > > > > ng/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          >   > > > > > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          >   > > > > > > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
          >   > > > > > > xmlns:xsd="http://www.w3.org/1999/XMLSchema">
          >   > > > > > >   <SOAP-ENV:Body>
          >   > > > > > >     <namesp1:getHoroscope xmlns:namesp1="urn:vgx-horoscope">
          >   > > > > > >       <c-gensym3 xsi:type="namesp2:SOAPStruct">
          >   > > > > > >         <astrology xsi:type="namesp2:SOAPStruct">
          >   > > > > > >           <sign xsi:type="xsd:string">aries</sign>
          >   > > > > > >         </astrology>
          >   > > > > > >       </c-gensym3>
          >   > > > > > >     </namesp1:getHoroscope>
          >   > > > > > >   </SOAP-ENV:Body>
          >   > > > > > > </SOAP-ENV:Envelope>
          >   > > > > > >
          >   > > > > > > I just want to get rid of "c-gensyn3" - unless of course
          >this
          >is
          >   > > > just
          >   > > > > > > SOAP serializing the data and I can be assured that it will
          >be
          >   > > > > > > deserialized properly...
          >   > > > > > >
          >   > > > > > > I agree the 'astrology' element is useless, but it is what
          >the
          >   > > > service
          >   > > > > > > calls for. :(
          >   > > > > > >
          >   > > > > > >
          >   > > > > > >
          >   > > > > > > On Mon, 2002-02-11 at 12:56, Duncan Cameron wrote:
          >   > > > > > > > On 2002-02-11 Byrne Reese wrote:
          >   > > > > > > > >There *must* be a way to do this more intuitively...
          >   > > > > > > > >
          >   > > > > > > > >I want to create a simple SOAP::Data struct which will
          >   > > > > > > serialize into
          >   > > > > > > > >this:
          >   > > > > > > > >
          >   > > > > > > > ><getHoroscope>
          >   > > > > > > > >   <astrology>
          >   > > > > > > > >      <sign>foo</sign>
          >   > > > > > > > >   </astrology>
          >   > > > > > > > ></getHoroscope>
          >   > > > > > > > >
          >   > > > > > > > >Here is my code:
          >   > > > > > > > >
          >   > > > > > > > >$body = SOAP::Data->name('astrology' =>
          >   > > > > > > SOAP::Data->name('sign' => $SIGN)
          >   > > > > > > > >                                        ->type('string')
          >);
          >   > > > > > > > This *seems* more intuitive:
          >   > > > > > > >
          >   > > > > > > > my $body = {'astrology' => {'sign' => 'aries'} };
          >   > > > > > > >
          >   > > > > > > > >It makes sense to me that if SOAP::Lite will properly
          >   > > > > > > serialize perl
          >   > > > > > > > >arrays and hashes, it should serialize nested scalars.
          >   > > > > > > > >
          >   > > > > > > > I think that the docs need to be clearer about exactly
          >   > > > > > > where a SOAP::Data
          >   > > > > > > > object can go. For example, is it valid to nest them as
          >you
          >   > > > > > > have tried?
          >   > > > > > > > In your case the first one ('astrology') is unnecessary as
          >   > > > > > > it doesn't add
          >   > > > > > > > anything.
          >   > > > > > > >
          >   > > > > > > > Regards,
          >   > > > > > > > Duncan Cameron
          >   > > > > > > >
          >   > > > > > > --
          >   > > > > > > :/ byrne
          >   > > > > > >
          >   > > > > > > breese@g...
          >   > > > > > > (415) 544-7732
          >   > > > > > >
          >   > > > > > > ------------------------ Yahoo! Groups Sponsor
          >   > > > > > > ---------------------~-->
          >   > > > > > > Sponsored by VeriSign - The Value of Trust
          >   > > > > > > When building an e-commerce site, you want to start with a
          >   > > > > > > secure foundation. Learn how with VeriSign's FREE Guide.
          >   > > > > > > http://us.click.yahoo.com/kWSNbC/XdiDAA/yigFAA/W6uqlB/TM
          >   > > > > > >
          >--------------------------------------------------------------
          >   > > > > > > -------~->
          >   > > > > > >
          >   > > > > > > To unsubscribe from this group, send an email to:
          >   > > > > > > soaplite-unsubscribe@y...
          >   > > > > > >
          >   > > > > > >
          >   > > > > > >
          >   > > > > > > Your use of Yahoo! Groups is subject to
          >   > > > > > http://docs.yahoo.com/info/terms/
          >   > > > > --
          >   > > > > :/ byrne
          >   > > > >
          >   > > > > breese@g...
          >   > > > > (415) 544-7732
          >   > > >
          >   > >--
          >   > >:/ byrne
          >   > >
          >   > >breese@...
          >   > >(415) 544-7732
          >   >
          >   >
          >   >
          >   >
          >   > _________________________________________________________________
          >   > MSN Photos is the easiest way to share and print your photos:
          >   > http://photos.msn.com/support/worldwide.aspx
          >   >
          >   --
          >   :/ byrne
          >
          >   breese@...
          >   (415) 544-7732
          >
          >         Yahoo! Groups Sponsor
          >               ADVERTISEMENT
          >
          >
          >
          >
          >   To unsubscribe from this group, send an email to:
          >   soaplite-unsubscribe@yahoogroups.com
          >
          >
          >
          >   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
          >




          _________________________________________________________________
          Send and receive Hotmail on your mobile device: http://mobile.msn.com



          To unsubscribe from this group, send an email to:
          soaplite-unsubscribe@yahoogroups.com



          Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


          To unsubscribe from this group, send an email to:
          soaplite-unsubscribe@yahoogroups.com



          Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        Your message has been successfully submitted and would be delivered to recipients shortly.