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

Re: Constructing a response as a collection of elements

Expand Messages
  • mitchbetterhavemybunny
    ... Almost. The resulting SOAP message then looks like this:
    Message 1 of 7 , Aug 28, 2004
    • 0 Attachment
      --- In soaplite@yahoogroups.com, Eric Amick <eric-amick@c...> wrote:
      > On 28 Aug 2004 11:08:55 -0000, you wrote:
      >
      >
      > Would something like this work?
      >
      > SOAP::Data->name('ConnectResponse' => \SOAP::Data->value(
      > SOAP::Data->name( 'messageversion' => '1.0' ),
      > SOAP::Data->name( 'sequence' => '123456' ),
      > SOAP::Data->name( 'status' => '0' ) ) );
      >

      Almost. The resulting SOAP message then looks like this:

      <soap:body>
      <a:ConnectResponse xmlns:a="urn:thisElementGetsCreatedForMe">
      <ConnectResponse>
      <messageversion>1.0</messageversion>
      ...
      </ConnectResponse>
      </a:ConnectResponse>
      </soap:body>

      The first ConnectResponse element is generated by SOAP::Lite as a
      response to the Connect operation, as expected. What I really want to
      do is either replace that element or add multiple children to it. I
      just don't see any obvious way to do that, as there always seems to be
      some user-created SOAP::Data object that represents the root of the
      response element tree.
    • Duncan Cameron
      On 2004-08-29 at 05:05:00 mitchbetterhavemybunny ... If you return a list then each entry will be sent immediately beneath the ConnectResponse element: return
      Message 2 of 7 , Aug 29, 2004
      • 0 Attachment
        On 2004-08-29 at 05:05:00 mitchbetterhavemybunny
        <mitchbetterhavemybunny@...> wrote:

        >--- In soaplite@yahoogroups.com, Eric Amick <eric-amick@c...> wrote:
        >> On 28 Aug 2004 11:08:55 -0000, you wrote:
        >>
        >> Would something like this work?
        >>
        >> SOAP::Data->name('ConnectResponse' => \SOAP::Data->value(
        >> SOAP::Data->name( 'messageversion' => '1.0' ),
        >> SOAP::Data->name( 'sequence' => '123456' ),
        >> SOAP::Data->name( 'status' => '0' ) ) );
        >>
        >Almost. The resulting SOAP message then looks like this:
        >
        ><soap:body>
        > <a:ConnectResponse xmlns:a="urn:thisElementGetsCreatedForMe">
        > <ConnectResponse>
        > <messageversion>1.0</messageversion>
        > ...
        > </ConnectResponse>
        > </a:ConnectResponse>
        ></soap:body>
        >
        >The first ConnectResponse element is generated by SOAP::Lite as a
        >response to the Connect operation, as expected. What I really want to
        >do is either replace that element or add multiple children to it. I
        >just don't see any obvious way to do that, as there always seems to be
        >some user-created SOAP::Data object that represents the root of the
        >response element tree.

        If you return a list then each entry will be sent immediately beneath
        the ConnectResponse element:

        return
        SOAP::Data->name(messageversion => '1.0'),
        SOAP::Data->name(sequence => '123456'),
        SOAP::Data->name(status => '0')
        ;
        Regards
        Duncan
      • Eric Amick
        ... I assume you meant return (SOAP::Data- name(messageversion = 1.0 ), SOAP::Data- name(sequence = 123456 ), SOAP::Data- name(status = 0 )) ; or is list
        Message 3 of 7 , Aug 29, 2004
        • 0 Attachment
          On 29 Aug 2004 10:46:19 -0000, you wrote:

          >If you return a list then each entry will be sent immediately beneath
          >the ConnectResponse element:
          >
          >return
          > SOAP::Data->name(messageversion => '1.0'),
          > SOAP::Data->name(sequence => '123456'),
          > SOAP::Data->name(status => '0')
          >;

          I assume you meant

          return
          (SOAP::Data->name(messageversion => '1.0'),
          SOAP::Data->name(sequence => '123456'),
          SOAP::Data->name(status => '0'))
          ;

          or is list context forced somehow?

          --
          Eric Amick
          Columbia, MD
        • Duncan Cameron
          ... I am not sure that context is the issue, rather the list is constructed first. The context of the call then dictates whether the list is returned in scalar
          Message 4 of 7 , Aug 29, 2004
          • 0 Attachment
            On 2004-08-29 at 13:55:09 Eric Amick <eric-amick@...> wrote:

            >
            >On 29 Aug 2004 10:46:19 -0000, you wrote:
            >
            >>If you return a list then each entry will be sent immediately beneath
            >>the ConnectResponse element:
            >>
            >>return
            >> SOAP::Data->name(messageversion => '1.0'),
            >> SOAP::Data->name(sequence => '123456'),
            >> SOAP::Data->name(status => '0')
            >>;
            >
            >I assume you meant
            >
            >return
            > (SOAP::Data->name(messageversion => '1.0'),
            > SOAP::Data->name(sequence => '123456'),
            > SOAP::Data->name(status => '0'))
            >;
            >
            >or is list context forced somehow?

            I am not sure that context is the issue, rather the list is constructed first. The context of the call then dictates whether the list is returned in scalar or list context. SOAP::Lite has to call the method in list context as it does not know beforehand what is going to be returned.

            Having said that, I agree that it is clearer to put the list in brackets!

            Regards
            Duncan
          • mitchbetterhavemybunny
            ... Perfect. Thank you, gentlemen, for sharing your insight. Scott Franklin
            Message 5 of 7 , Aug 30, 2004
            • 0 Attachment
              --- In soaplite@yahoogroups.com, Eric Amick <eric-amick@c...> wrote:
              > >If you return a list then each entry will be sent immediately beneath
              > >the ConnectResponse element:
              > >
              > >return
              > > SOAP::Data->name(messageversion => '1.0'),
              > > SOAP::Data->name(sequence => '123456'),
              > > SOAP::Data->name(status => '0')
              > >;
              >

              Perfect. Thank you, gentlemen, for sharing your insight.

              Scott Franklin
            Your message has been successfully submitted and would be delivered to recipients shortly.