Page 1 of 1

soap and complexType's

Posted: Tue Jan 31, 2006 3:42 pm
by eiku
Hi

I've been trying to create testcase for webservices using PHP5's SOAP but there is something i am missing or that is not documentet like it should... anyway. Maybe someone has an answer.

I have the SOAP server and client both in PHP5 and in server I try to implement a service that returns complexType/array of complextypes as the result. The wsdl looks something like this:

Code: Select all

<complexType name="itemType">
	<complexContent>
		<sequence>
			<element name="title" type="xsd:string" />
			<element name="location" type="xsd:string" />
		</sequence>
	</complexContent>
</complexType>
<complexType name="anArrayType">
	<complexContent>
    		<restriction base="SOAP-ENC:Array">
			<sequence>
				<element name="item" type="tns:itemType" minOccurs="0" maxOccurs="unbound" />
			</sequence>
		</restriction>
	</complexContent>
</complexType>
...
<message name="emptyMessage" />
<message name="anArrayResponse">
	<part name="anArray" type="tns:anArrayType" />
</message>
...
<operation name="getAnArray">
	<input message="tns:emptyMessage"/>
	<output message="tns:anArrayResponse"/>
</operation>
The client implementation is fairly simple (too):

Code: Select all

<?php
	ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
	$client = new SoapClient(MY-WSDL-FILE-URL);
	$result = $client->getAnArray();
?>
The code fails with the following exception:
SOAP-ERROR: Encoding: object hasn't 'title' property
Something is like not quite right... if I give a simple type as output then the whole thing works as it should... but as soon as I introduce complexType as responce... (i'm not quite sure but it seems) no request is composed by the soap client. Seems as the client expects the input to be an complexType... am I missing something or is this normal behaviour?

Thanks for any ideas... as I am out of my own.
Heiko