Complex Types problem

[email protected] (Dani Castaños)
Newsgroups php.soap
Message-ID <[email protected]>
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) '[email protected]'
                   , '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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.