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

Re: [soaplite] Remove Generated Elements From Response

Expand Messages
  • Duncan Cameron
    At 2005-03-29, 15:09:07 jameshargreavesgmail ... I guess that your server code is something like return {SessionID = 422496dfa941e70045f3b910bafa9a3c }; This
    Message 1 of 3 , Mar 29, 2005
      At 2005-03-29, 15:09:07 jameshargreavesgmail
      <james.hargreaves@...> wrote:

      >I have written a SOAP Server for an application I am working on. The
      >response looks something like this:
      >
      ><?xml version="1.0" encoding="UTF-8"?>
      ><SOAP-ENV:Envelope
      >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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      > <SOAP-ENV:Body>
      > <namesp2:LoginResponse xmlns:namesp2="urn:SOAPAtlas3">
      > <s-gensym6>
      > <SessionID
      >xsi:type="xsd:string">422496dfa941e70045f3b910bafa9a3c</SessionID>
      > </s-gensym6>
      > </namesp2:LoginResponse>
      > </SOAP-ENV:Body>
      ></SOAP-ENV:Envelope>
      >
      >You'll note that the <s-gensym6> element is generated automatically by
      >SOAP::Lite. This is causing my client to mis-interpret the response. I
      >need the response to appear as follows:
      >
      ><?xml version="1.0" encoding="UTF-8"?>
      ><SOAP-ENV:Envelope
      >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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      > <SOAP-ENV:Body>
      > <namesp2:LoginResponse xmlns:namesp2="urn:SOAPAtlas3">
      > <SessionID
      >xsi:type="xsd:string">422496dfa941e70045f3b910bafa9a3c</SessionID>
      > </namesp2:LoginResponse>
      > </SOAP-ENV:Body>
      ></SOAP-ENV:Envelope>
      >
      >Is there a way to remove these automatically generated elements?
      >
      >Thanks
      >Jay
      >
      I guess that your server code is something like
      return {SessionID => '422496dfa941e70045f3b910bafa9a3c'};

      This should do what you are looking for

      return SOAP::Data
      ->name(SessionId => '422496dfa941e70045f3b910bafa9a3c')
      ->type('string')
      ;

      Duncan



      Send instant messages to your online friends http://uk.messenger.yahoo.com
    • Jay Hargreaves
      Thanks Duncan - that s just what I was after! With the answer to my previous question in mind how would I create the following structure using SOAP::Data in a
      Message 2 of 3 , Mar 30, 2005
        Thanks Duncan - that's just what I was after!

        With the answer to my previous question in mind how would I create the
        following structure using SOAP::Data in a similar way:

        <modules>
        <module>
        <country>aus</country>
        <class>ah21</class>
        <description>AH21PCIX Module - AUSTRALIAN data</description>
        <module_id>ah21_aus</module_id>
        </module>
        <module>
        <country>uk</country>
        <class>ah21</class>
        <description>AH21PCIX Module - UK data</description>
        <module_id>ah21_uk</module_id>
        </module>
        <module>
        <country>aus</country>
        <class>listapi</class>
        <description>List API Module - AUSTRALIAN data</description>
        <module_id>listapi_aus</module_id>
        </module>
        <module>
        <country>uk</country>
        <class>listapi</class>
        <description>List API Module - UK data</description>
        <module_id>listapi_uk</module_id>
        </module>
        </modules>

        I currently have this information stored as an array of hashes and it
        is returned as follows:

        <?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope
        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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <SOAP-ENV:Body>
        <namesp8:modulesResponse
        xmlns:namesp8="http://test.rigadon.com/SOAPModules">
        <SOAP-ENC:Array xsi:type="SOAP-ENC:Array"
        SOAP-ENC:arrayType="xsd:ur-type[4]">
        <item>
        <country xsi:type="xsd:string">aus</country>
        <class xsi:type="xsd:string">ah21</class>
        <description xsi:type="xsd:string">AH21PCIX Module -
        AUSTRALIAN data</description>
        <module_id xsi:type="xsd:string">ah21_aus</module_id>
        </item>
        <item>
        <country xsi:type="xsd:string">uk</country>
        <class xsi:type="xsd:string">ah21</class>
        <description xsi:type="xsd:string">AH21PCIX Module - UK
        data</description>
        <module_id xsi:type="xsd:string">ah21_uk</module_id>
        </item>
        <item>
        <country xsi:type="xsd:string">aus</country>
        <class xsi:type="xsd:string">listapi</class>
        <description xsi:type="xsd:string">List API Module -
        AUSTRALIAN data</description>
        <module_id xsi:type="xsd:string">listapi_aus</module_id>
        </item>
        <item>
        <country xsi:type="xsd:string">uk</country>
        <class xsi:type="xsd:string">listapi</class>
        <description xsi:type="xsd:string">List API Module - UK
        data</description>
        <module_id xsi:type="xsd:string">listapi_uk</module_id>
        </item>
        </SOAP-ENC:Array>
        </namesp8:modulesResponse>
        </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>

        Thanks
        Jay

        On Tue, 29 Mar 2005 15:34:56 +0100 (BST), Duncan Cameron
        <duncan_cameron2002@...> wrote:
        > At 2005-03-29, 15:09:07 jameshargreavesgmail
        > <james.hargreaves@...> wrote:
        >
        > >I have written a SOAP Server for an application I am working on. The
        > >response looks something like this:
        > >
        > ><?xml version="1.0" encoding="UTF-8"?>
        > ><SOAP-ENV:Envelope
        > >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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > > <SOAP-ENV:Body>
        > > <namesp2:LoginResponse xmlns:namesp2="urn:SOAPAtlas3">
        > > <s-gensym6>
        > > <SessionID
        > >xsi:type="xsd:string">422496dfa941e70045f3b910bafa9a3c</SessionID>
        > > </s-gensym6>
        > > </namesp2:LoginResponse>
        > > </SOAP-ENV:Body>
        > ></SOAP-ENV:Envelope>
        > >
        > >You'll note that the <s-gensym6> element is generated automatically by
        > >SOAP::Lite. This is causing my client to mis-interpret the response. I
        > >need the response to appear as follows:
        > >
        > ><?xml version="1.0" encoding="UTF-8"?>
        > ><SOAP-ENV:Envelope
        > >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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > > <SOAP-ENV:Body>
        > > <namesp2:LoginResponse xmlns:namesp2="urn:SOAPAtlas3">
        > > <SessionID
        > >xsi:type="xsd:string">422496dfa941e70045f3b910bafa9a3c</SessionID>
        > > </namesp2:LoginResponse>
        > > </SOAP-ENV:Body>
        > ></SOAP-ENV:Envelope>
        > >
        > >Is there a way to remove these automatically generated elements?
        > >
        > >Thanks
        > >Jay
        > >
        > I guess that your server code is something like
        > return {SessionID => '422496dfa941e70045f3b910bafa9a3c'};
        >
        > This should do what you are looking for
        >
        > return SOAP::Data
        > ->name(SessionId => '422496dfa941e70045f3b910bafa9a3c')
        > ->type('string')
        > ;
        >
        > Duncan
        >
        > Send instant messages to your online friends http://uk.messenger.yahoo.com
        >


        --
        a: 18 hart street, altrincham, wa14 1jw
        m: 07899 872 306
        e: james.hargreaves@...
      Your message has been successfully submitted and would be delivered to recipients shortly.