I'm having trouble finding a solid example of a simple array in a wrapped document / literal style.
Consider a PHP function that generates an array to its maximum value.
public function countTo($max) { $array = array(); for ($i = 0; $i < $max; $i++) { $array[] = 'Number: ' . ($i + 1); } return $array; }
The WSDL types generated for this are:
<xsd:complexType name="countTo"> <xsd:sequence> <xsd:element name="max" type="xsd:int"/> </xsd:sequence> </xsd:complexType> <xsd:element name="countTo" nillable="true" type="ns:countTo"/> <xsd:complexType name="ArrayOfCount"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="count" nillable="true" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="countToResponse"> <xsd:sequence> <xsd:element name="count" type="ns:ArrayOfCount"/> </xsd:sequence> </xsd:complexType> <xsd:element name="countToResponse" nillable="true" type="ns:countToResponse"/>
The request in the body will look like this:
<ns1:countTo> <max>5</max> </ns1:countTo>
But what does the answer look like, and what is an agreement?
SoapServer is currently generating
<ns1:countToResponse> <count> <count>Number: 1</count> <count>Number: 2</count> <count>Number: 3</count> <count>Number: 4</count> <count>Number: 5</count> </count> </ns1:countToResponse>
I'm not sure about the nested count elements. Perhaps it should be instead of item (and the WSDL will need to be updated to make this happen).
<ns1:countToResponse> <count> <item>Number: 1</item> <item>Number: 2</item> <item>Number: 3</item> <item>Number: 4</item> <item>Number: 5</item> </count> </ns1:countToResponse>
arrays soap xml php
Reuben
source share