I've a web-service function which is returning an array of items to a PHP-Client. Depending on the number of items, the PHP return type is differently. If the function returns one item the PHP type is stdClass
if the function returns more than one item, the PHP type is array
. In either case it should be array
. What can I do to achieve this?
Details:
Avar_dump
of the result from the web-service function looks like following:
- if one item is in the result:
array(3) { ["filterErg"]=> object(stdClass)#37 (1) { ["item"]=> object(stdClass)#38 (9) ...
- if more than one item is in the result:
array(3) { ["filterErg"]=> object(stdClass)#37 (1) { ["item"]=> array(16) ...
The name of the function is getFilter
and the relevant parts of the WSDL File are:
<types>
<schema ...>
<complexType name="arrayFilter">
<sequence>
<element name="item" type="ns1:stFilter" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
...
</schema>
</types>
<message name="getFilterResponse">
<part name="filterErg" type="ns1:arrayFilter"/>
<part name="functionResult" type="xsd:int"/>
<part name="outErr" type="xsd:string"/>
</message>
<portType name="ADServicePortType">
<operation name="getFilter">
<documentation>Service definition of function ns1__getFilter</documentation>
<input message="tns:getFilter"/>
<output message="tns:getFilterResponse"/>
</operation>
...
</portType>
<binding name="ADService" type="tns:ADServicePortType">
<SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getFilter">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:ADService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:ADService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
...
</binding>