How to encode PHP object to nuSOAP response?

TGF

New Member
I'm building a simple WebService. I have a User PHP class and a webmethod getUser to retrieve a user's information.I've declared a complexType and everything seems to work perfectly.\[code\]$server->wsdl->addComplexType('User', 'complexType','struct', 'all', '', array( 'id' => array('name' => 'id', 'type' => 'xsd:int'), 'username' => array('name' => 'username','type' => 'xsd:string'), 'password' => array('name' => 'password','type' => 'xsd:string'), 'email' => array('name' => 'email','type' => 'xsd:string'), 'authority' => array('name' => 'authority','type' => 'xsd:int'), 'isActive' => array('name' => 'isActive','type' => 'xsd:int'), 'area' => array('name' => 'area','type' => 'xsd:string') ));$server->register('ws_getUser', array('user_id' => 'xsd:integer'), array('user' => 'tns:User'), $namespace, "$namespace#ws_getUser", 'rpc', 'encoded', 'Retorna un usuario');function ws_getUser($user_id){ return new soapval('return', 'tns:User', getUser($user_id));}\[/code\]However, on the getUser function I'm retrieving the user info as an assoc. array, not the User Object itself.What I would like to do on getUser is to return a User instance instead, and have nuSOAP serialize it for me. Is this possible?Edit: I've tried returning a new User() for testing purposes, but the response is \[code\]<user xsi:type="tns:User"/>\[/code\]
 
Back
Top