views:

1131

answers:

3

Hi all,

How can I define an associative array in a SOAP wsdl file? This is how I define an array element type so far:

<wsdl:types>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="webservice.wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;
  <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
  <xsd:complexType name="ArrayOfString">
   <xsd:complexContent>
    <xsd:restriction base="soapenc:Array">
     <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:arrayElement"/>
    </xsd:restriction>
   </xsd:complexContent>
  </xsd:complexType>
 </xsd:schema>
</wsdl:types>

Thanks!

+1  A: 

If you want to use an array of strings you may just declare in the type that needs the array:

<xs:complexType name="SomeTypeThatUsesAnArrayOfStrings">
    <xs:sequence>
        <xs:element name="TheStringValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

And by the way, what do you mean with "associative array"? something like a c++ map or a python dictionary?

Paolo Tedesco
A: 

I'm talking about PHP associative arrays, and I want to use any number of any key=>value string pairs, that will be converted back to associative arrays on the other side of the communication party. As an alternative, I could send the serialized array, or json representation as string, but I'd like to know how to do this in wsdl also.

Thanks!

Ch4m3l3on
+2  A: 

WSDL cannot describe the associative nature of an associative array. The best you could do would be to define an array of name/value.

Can you define a PHP service with an operation that returns an associative array, then see what WSDL that produces? You could then follow the same pattern in your own, hand-written WSDLs.

John Saunders