I have a PHP web service with NuSOAP i have a complex type then same as another post on stack see below:
#SERVER
$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));
}
#CLIENT
require_once('./classes/nusoaplib/nusoap.php');
$client = new soapclient('http://localhost/api.php?wsdl');
$result = $client->__call('ws_getUser', array('id' => '1', 'username' => 'user', 'password' => 'pass', 'email' => 'user@email.co.za', 'authority' => '1', 'isActive' => '1', 'area' => 'usa'));
// Display the result
var_dump($result);
But i keep getting errors from the service i have tried a lot of different type of changes to the complex type but keep getting the same errors.
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\api.php:26 Stack trace: #0 C:\wamp\www\api.php(26): SoapClient->__call('ws_getUser', Array) #1 {main} thrown in C:\wamp\www\api.php on line 26
Im using wamp with PHP 5.4.3 and Nusoap library 0.9.5 If anyone can tell me what the problem is Thanks
I figured it out using wamp i enabled soap extensions and every time i registered the client or server it found the classes for the default soap instead of nusoap
CORRECT $client = new nusoap_client('http://localhost/nusoap/server.php?wsdl'); INCORRECT $client = new soapclient('http://localhost/nusoap/server.php?wsdl');
same with the servers.
The php error i receive was because of this as well as it is not formatted in the correct way. Normal soap ext returns it as a stdClass.