soap and complexType's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eiku
Forum Newbie
Posts: 1
Joined: Tue Jan 31, 2006 3:20 pm
Location: Tallinn

soap and complexType's

Post 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
Post Reply