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

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

Expand Messages
  • John Powell
    Feb 13, 2002
      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


      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.
    • Show all 10 messages in this topic