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

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

Expand Messages
  • Leon de Rooij
    Aug 16, 2004
    • 0 Attachment

      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">
      <xsd:element name="status" minOccurs="0" maxOccurs="1"
      <xsd:element name="mac" minOccurs="0" maxOccurs="unbounded"
      <xsd:element name="ip" minOccurs="0" maxOccurs="1"

      <xsd:complexType name="service">
      <xsd:element name="dhcp" minOccurs="0" maxOccurs="unbounded"
      <xsd:element name="www" minOccurs="0" maxOccurs="unbounded"

      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">
      <dhcp xsi:type="ns1:dhcpservice">

      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' => ''
      }, '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..


      Leon de Rooij