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

WSDL return value only contains last record

Expand Messages
  • dub357
    I have a simple web service implemented in Java that takes in a single string value and returns an array of StaffBeans , each holding a persons name, email,
    Message 1 of 4 , Oct 25, 2004
    • 0 Attachment
      I have a simple web service implemented in Java that takes in a single
      string value and returns an array of "StaffBeans", each holding a
      persons name, email, phone, etc. Here is the schema from the WSDL:

      <xsd:complexType name="ArrayOfStaffBean">
      <xsd:complexContent>
      <xsd:restriction base="soapenc:Array">
      <xsd:attribute ref="soapenc:arrayType"
      wsdl:arrayType="stns:StaffBean[]">
      </xsd:attribute>
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>
      <xsd:complexType name="StaffBean">
      <xsd:sequence>
      <xsd:element type="xsd:string" name="bldgAndRoom"></xsd:element>
      <xsd:element type="xsd:string" name="division"></xsd:element>
      <xsd:element type="xsd:string" name="email"></xsd:element>
      <xsd:element type="xsd:string" name="fullname"></xsd:element>
      <xsd:element type="xsd:string" name="mailstop"></xsd:element>
      <xsd:element type="xsd:string" name="pager"></xsd:element>
      <xsd:element type="xsd:string" name="phone"></xsd:element>
      </xsd:sequence>
      </xsd:complexType>

      The problem is, when the return comes back from the SOAP call, only
      the last object is returned. If the input matches 4 people, only the
      last person is returned from the method call.
      Here is an example of the SOAP message body returned for 2 people
      matching the input "akers":

      <ArrayOfStaffBean>
      <StaffBean>
      <bldgAndRoom>16 / 176</bldgAndRoom>
      <division>PHY</division>
      <email>****@...</email>
      <fullname>Akers, Evelyn</fullname>
      <mailstop>16A</mailstop>
      <pager>757-***-7729+</pager>
      <phone>7729</phone>
      </StaffBean>
      <StaffBean>
      <bldgAndRoom>16 / 166</bldgAndRoom>
      <division>CIO</division>
      <email>****@...</email>
      <fullname>Akers, Walt</fullname>
      <mailstop>16A</mailstop>
      <pager></pager>
      <phone>7669</phone>
      </StaffBean>
      </ArrayOfStaffBean>

      When I do a Data:Dumper on the return value (a hash), I only get the
      last record for Akers, Walt:
      $VAR1 = {
      'StaffBean' => {
      'mailstop' => '16A',
      'email' => '****@...',
      'division' => 'CIO',
      'fullname' => 'Akers, Walt',
      'bldgAndRoom' => '16 / 166',
      'pager' => '',
      'phone' => '7669'
      }
      };

      Has anyone else experienced this or know of a workaround? I suspect
      that it may be a bug of some kind...
    • Duncan Cameron
      ... This was a known feature but has been remedied (Hurray!) in the latest 0.65 beta release. From the changes file: ! Fix a bug in which doclit style
      Message 2 of 4 , Oct 25, 2004
      • 0 Attachment
        At 2004-10-25, 15:20:54 dub357 <dub357@...> wrote:

        >I have a simple web service implemented in Java that takes in a single
        >string value and returns an array of "StaffBeans", each holding a
        >persons name, email, phone, etc. Here is the schema from the WSDL:
        >
        ><xsd:complexType name="ArrayOfStaffBean">
        > <xsd:complexContent>
        > <xsd:restriction base="soapenc:Array">
        > <xsd:attribute ref="soapenc:arrayType"
        >wsdl:arrayType="stns:StaffBean[]">
        > </xsd:attribute>
        > </xsd:restriction>
        > </xsd:complexContent>
        ></xsd:complexType>
        ><xsd:complexType name="StaffBean">
        > <xsd:sequence>
        > <xsd:element type="xsd:string" name="bldgAndRoom"></xsd:element>
        > <xsd:element type="xsd:string" name="division"></xsd:element>
        > <xsd:element type="xsd:string" name="email"></xsd:element>
        > <xsd:element type="xsd:string" name="fullname"></xsd:element>
        > <xsd:element type="xsd:string" name="mailstop"></xsd:element>
        > <xsd:element type="xsd:string" name="pager"></xsd:element>
        > <xsd:element type="xsd:string" name="phone"></xsd:element>
        > </xsd:sequence>
        ></xsd:complexType>
        >
        >The problem is, when the return comes back from the SOAP call, only
        >the last object is returned. If the input matches 4 people, only the
        >last person is returned from the method call.
        >Here is an example of the SOAP message body returned for 2 people
        >matching the input "akers":
        >
        ><ArrayOfStaffBean>
        > <StaffBean>
        > <bldgAndRoom>16 / 176</bldgAndRoom>
        > <division>PHY</division>
        > <email>****@...</email>
        > <fullname>Akers, Evelyn</fullname>
        > <mailstop>16A</mailstop>
        > <pager>757-***-7729+</pager>
        > <phone>7729</phone>
        > </StaffBean>
        > <StaffBean>
        > <bldgAndRoom>16 / 166</bldgAndRoom>
        > <division>CIO</division>
        > <email>****@...</email>
        > <fullname>Akers, Walt</fullname>
        > <mailstop>16A</mailstop>
        > <pager></pager>
        > <phone>7669</phone>
        > </StaffBean>
        ></ArrayOfStaffBean>
        >
        >When I do a Data:Dumper on the return value (a hash), I only get the
        >last record for Akers, Walt:
        >$VAR1 = {
        > 'StaffBean' => {
        > 'mailstop' => '16A',
        > 'email' => '****@...',
        > 'division' => 'CIO',
        > 'fullname' => 'Akers, Walt',
        > 'bldgAndRoom' => '16 / 166',
        > 'pager' => '',
        > 'phone' => '7669'
        > }
        > };
        >
        >Has anyone else experienced this or know of a workaround? I suspect
        >that it may be a bug of some kind...
        >
        This was a 'known feature' but has been remedied (Hurray!) in the
        latest 0.65 beta release. From the 'changes' file:

        ! Fix a bug in which doclit style arrays were not being deserialized
        properly. IOW, Repeated elements were not made into an array, only
        the last occurring value was recorded.

        You don't say which release of SOAP::Lite you are using. Can you
        install the latest and confirm whether that fixes the problem?

        Paul/Byrne - maybe the inclusion of this fix should be promoted more
        prominently as the problem has been a FAQ for several years.

        Regards
        Duncan
      • Igor Korolev
        You can deal with this even using the older versions. Something like: my $res = $som- result(); my @beans =
        Message 3 of 4 , Oct 25, 2004
        • 0 Attachment
          You can deal with this even using the older versions. Something like:

          my $res = $som->result();
          my @beans =
          $som->valueof('//yourPathAboveArrayOfStaffBean/ArrayOfStaffBean/StaffBea
          n');

          -----Original Message-----
          From: Duncan Cameron [mailto:duncan_cameron2002@...]
          Sent: Monday, October 25, 2004 10:19 AM
          To: dub357; soaplite@yahoogroups.com
          Subject: Re: [soaplite] WSDL return value only contains last record


          At 2004-10-25, 15:20:54 dub357 <dub357@...> wrote:

          >I have a simple web service implemented in Java that takes in a single
          >string value and returns an array of "StaffBeans", each holding a
          >persons name, email, phone, etc. Here is the schema from the WSDL:
          >
          ><xsd:complexType name="ArrayOfStaffBean">
          > <xsd:complexContent>
          > <xsd:restriction base="soapenc:Array">
          > <xsd:attribute ref="soapenc:arrayType"
          >wsdl:arrayType="stns:StaffBean[]">
          > </xsd:attribute>
          > </xsd:restriction>
          > </xsd:complexContent>
          ></xsd:complexType>
          ><xsd:complexType name="StaffBean">
          > <xsd:sequence>
          > <xsd:element type="xsd:string" name="bldgAndRoom"></xsd:element>
          > <xsd:element type="xsd:string" name="division"></xsd:element>
          > <xsd:element type="xsd:string" name="email"></xsd:element>
          > <xsd:element type="xsd:string" name="fullname"></xsd:element>
          > <xsd:element type="xsd:string" name="mailstop"></xsd:element>
          > <xsd:element type="xsd:string" name="pager"></xsd:element>
          > <xsd:element type="xsd:string" name="phone"></xsd:element>
          > </xsd:sequence>
          ></xsd:complexType>
          >
          >The problem is, when the return comes back from the SOAP call, only the

          >last object is returned. If the input matches 4 people, only the last
          >person is returned from the method call.
          >Here is an example of the SOAP message body returned for 2 people
          >matching the input "akers":
          >
          ><ArrayOfStaffBean>
          > <StaffBean>
          > <bldgAndRoom>16 / 176</bldgAndRoom>
          > <division>PHY</division>
          > <email>****@...</email>
          > <fullname>Akers, Evelyn</fullname>
          > <mailstop>16A</mailstop>
          > <pager>757-***-7729+</pager>
          > <phone>7729</phone>
          > </StaffBean>
          > <StaffBean>
          > <bldgAndRoom>16 / 166</bldgAndRoom>
          > <division>CIO</division>
          > <email>****@...</email>
          > <fullname>Akers, Walt</fullname>
          > <mailstop>16A</mailstop>
          > <pager></pager>
          > <phone>7669</phone>
          > </StaffBean>
          ></ArrayOfStaffBean>
          >
          >When I do a Data:Dumper on the return value (a hash), I only get the
          >last record for Akers, Walt:
          >$VAR1 = {
          > 'StaffBean' => {
          > 'mailstop' => '16A',
          > 'email' => '****@...',
          > 'division' => 'CIO',
          > 'fullname' => 'Akers, Walt',
          > 'bldgAndRoom' => '16 / 166',
          > 'pager' => '',
          > 'phone' => '7669'
          > }
          > };
          >
          >Has anyone else experienced this or know of a workaround? I suspect
          >that it may be a bug of some kind...
          >
          This was a 'known feature' but has been remedied (Hurray!) in the latest
          0.65 beta release. From the 'changes' file:

          ! Fix a bug in which doclit style arrays were not being deserialized
          properly. IOW, Repeated elements were not made into an array, only
          the last occurring value was recorded.

          You don't say which release of SOAP::Lite you are using. Can you install
          the latest and confirm whether that fixes the problem?

          Paul/Byrne - maybe the inclusion of this fix should be promoted more
          prominently as the problem has been a FAQ for several years.

          Regards
          Duncan




          ------------------------ Yahoo! Groups Sponsor --------------------~-->
          $9.95 domain names from Yahoo!. Register anything.
          http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/W6uqlB/TM
          --------------------------------------------------------------------~->


          Yahoo! Groups Links
        • Duncan Cameron
          ... That s right, but now we can get the data by something like $som- result- {StaffBean}- [0]; Note that the element ArrayOfStaffBean does not need to be
          Message 4 of 4 , Oct 25, 2004
          • 0 Attachment
            At 2004-10-25, 17:21:52 Igor Korolev <ikorolev@...> wrote:

            >
            >You can deal with this even using the older versions. Something like:
            >
            > my $res = $som->result();
            > my @beans =
            >$som->valueof('//yourPathAboveArrayOfStaffBean/ArrayOfStaffBean/StaffBean');

            That's right, but now we can get the data by something like

            $som->result->{StaffBean}->[0];

            Note that the element ArrayOfStaffBean does not need to be referenced (although it does exist in the SOM object)

            Regards
            Duncan
          Your message has been successfully submitted and would be delivered to recipients shortly.