Hi!
I'm trying to do a simple WS call with a parameter that should be built
as ComplexType. I receive a "Cannot use object of type stdClass as
array" error, I have try several things and the code is not working out.
Here is my code:
WSDL
=====
<xsd:complexType name="SubscriberDataType">
<xsd:all>
<xsd:element name="age" type="xsd:integer"/>
<xsd:element name="email" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
[...]
<message name="CreateSubscriber">
<part name="subscriber" type="typens:SubscriberDataType"/>
</message>
<message name="CreateSubscriberResponse">
<part name="CreateSubscriberReturn" type="xsd:integer"/>
</message>
PHP CLIENT
==========
<?php
define( 'WS_WSDL', 'http://hannibal/poc/PHP5_SOAP/wsdl/subscribers.wsdl' );
$client = new SoapClient( WS_WSDL );
$subscriber = array( 'age' => (Integer) 27
, 'email' => (String) 'foo@fake.es'
, 'name' => (String) 'Dani'
);
try
{
$result = $client->CreateSubscriber( $subscriber );
echo $result;
}
catch( SoapFault $exception )
{
echo $exception->faultstring;
}
?>
PHP SERVER
==========
<?php
define( 'WS_WSDL',
'http://localhost/poc/PHP5_SOAP/wsdl/subscribers.wsdl' );
function CreateSubscriber( $subscriber )
{
$name = $subscriber['name'];
$email = $subscriber['email'];
$age = $subscriber['age'];
return 200;
}//function CreateSubscriber( $name )
/******************/
class SubscriberDataType
{
public $age;
public $email;
public $name;
}//class SubscriberDataType
/*----------------MAIN-----------------*/
$server = new SoapServer( WS_WSDL );
$server->addFunction( 'CreateSubscriber' );
$server->handle( $GLOBALS['HTTP_RAW_POST_DATA'] );
die;
?>
Thank you in advance!
Dani
--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php