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

Constructing a response as a collection of elements

Expand Messages
  • mitchbetterhavemybunny
    I think this should be a pretty basic question, but I can t seem to find anybody who has asked it yet here in the archives. Essentially, I am trying to write
    Message 1 of 7 , Aug 27, 2004
    • 0 Attachment
      I think this should be a pretty basic question, but I can't seem to
      find anybody who has asked it yet here in the archives. Essentially,
      I am trying to write a server that will return a series of elements as
      direct children of the response element. The messsage section of my
      WSDL file looks like this:

      <message name="ConnectResponse">

      <part name="messageversion" type="xsd:string"/>

      <part name="sequence" type="xsd:int"/>

      <part name="status" type="xsd:int"/>

      </message>

      Which should look something like this in the message body:

      <ConnectResponse>
      <messageversion>1.0</messageversion>
      <sequence>123456</sequence>
      <status>0</status>
      </ConnectRespone>

      I can generate the three child elements by using an anonymous
      reference to a SOAP::Data object, but I don't see how to attach them
      to the actual response element. The closest I seem to come is
      something like the following:

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

      This, however, wraps my three child elements in yet another element
      named (helpfully) "s-gensym8". I really just want them to be direct
      children of the ConnectResponse element, but I don't see how I can do
      that without writing my own serializer. Is there some less painful
      way to do this?

      thanks,
      Scott Franklin
    • Eric Amick
      ... Would something like this work? SOAP::Data- name( ConnectResponse = SOAP::Data- value( SOAP::Data- name( messageversion = 1.0 ), SOAP::Data- name(
      Message 2 of 7 , Aug 28, 2004
      • 0 Attachment
        On 28 Aug 2004 11:08:55 -0000, you wrote:

        >Which should look something like this in the message body:
        >
        ><ConnectResponse>
        > <messageversion>1.0</messageversion>
        > <sequence>123456</sequence>
        > <status>0</status>
        ></ConnectRespone>
        >
        >I can generate the three child elements by using an anonymous
        >reference to a SOAP::Data object, but I don't see how to attach them
        >to the actual response element. The closest I seem to come is
        >something like the following:
        >
        >SOAP::Data->value( \SOAP::Data->value(
        > SOAP::Data->name( 'messageversion' => '1.0' ),
        > SOAP::Data->name( 'sequence' => '123456' ),
        > SOAP::Data->name( 'status' => '0' ) ) );

        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' ) ) );

        --
        Eric Amick
        Columbia, MD
      • mitchbetterhavemybunny
        ... Almost. The resulting SOAP message then looks like this:
        Message 3 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 4 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 5 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 6 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 7 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.