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

Sending SOAP message with multiple entries in an associative array with the same key

Expand Messages
  • Leon de Rooij
    Hi, I am trying to parse a SOAP request with SOAP::Lite which contain an associative array with multiple entries with the same key. Unfortunately SOAP::Lite
    Message 1 of 1 , Aug 16, 2004
    • 0 Attachment
      Hi,

      I am trying to parse a SOAP request with SOAP::Lite which contain an
      associative array with multiple entries with the same key. Unfortunately
      SOAP::Lite overwrites the first entry with the second entry.

      This is part of the WSDL that I wrote for it:

      ....
      <xsd:complexType name="dhcpservice">
      <sequence>
      <xsd:element name="status" minOccurs="0" maxOccurs="1"
      type="xsd:string"/>
      <xsd:element name="mac" minOccurs="0" maxOccurs="unbounded"
      type="xsd:string"/>
      <xsd:element name="ip" minOccurs="0" maxOccurs="1"
      type="xsd:string"/>
      </sequence>
      </xsd:complexType>

      <xsd:complexType name="service">
      <sequence>
      <xsd:element name="dhcp" minOccurs="0" maxOccurs="unbounded"
      type="typens:dhcpservice"/>
      <xsd:element name="www" minOccurs="0" maxOccurs="unbounded"
      type="typens:wwwservice"/>
      </sequence>
      </xsd:complexType>
      ....

      Now, I want to be able to send a complexType 'service' which can contain
      more than one 'dhcpservice' objects.

      My colleague who uses gSoap sends the following SOAP Request (partly,
      for easier reading):

      ....
      <service xsi:type="ns1:service">
      <dhcp xsi:type="ns1:dhcpservice">
      <status>active</status>
      <mac>00:00:00:00:00:00</mac>
      <ip>1.2.3.4</ip>
      </dhcp>
      <dhcp xsi:type="ns1:dhcpservice">
      <status>inactive</status>
      <mac>11:11:11:11:11:11</mac>
      <ip>4.3.2.1</ip>
      </dhcp>
      </service>
      ....

      And when I then Dump the data that I get in SOAP::Lite, it's just the
      second dhcpservice. It looks like the first one gets overwritten:

      $VAR1 = bless( {
      'dhcp' => bless( {
      'status' => 'inactive',
      'mac' => '11:11:11:11:11:11',
      'ip' => '4.3.2.1'
      }, 'dhcpservice' )
      }, 'service' );

      Sounds logical of course, as an associative array can only have
      key/value pairs wherein the key has to be unique.

      I tried working around this by making an extra array which contains
      these objects, and it works, but everything gets really ugly that way.

      Is there a way so I can still get more than one object with the same key
      and while still using this WSDL ? As I said, gSOAP has no problem with
      it at all, but my only option is to use perl for this.. Maybe there's
      something that I can do with (de-)serializing, but that's looking quite
      complicated from what I read in the docs..

      Anyway, thanks in advance..

      Regards,

      Leon de Rooij
      leon@...
    Your message has been successfully submitted and would be delivered to recipients shortly.