You can t return an array like this. To return an array, you have to define a complex type.
I ll provide u an example...
The server program service.php
:
<?php
// Pull in the NuSOAP code
require_once( lib/nusoap.php );
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL( RM , urn:RM );
//Define complex type
$server->wsdl->addComplexType(
User ,
complexType ,
struct ,
all ,
,
array(
Id => array( name => Id , type => xsd:int ),
Name => array( name => Name , type => xsd:string ),
Email => array( name => Email , type => xsd:string ),
Description => array( name => Description , type => xsd:string )
)
);
// Register the method
$server->register( GetUser , // method name
array( UserName => xsd:string ), // input parameters
array( User => tns:User ), // output parameters
urn:RM , // namespace
urn:RM#GetUser , // soapaction
rpc , // style
encoded , // use
Get User Details // documentation
);
function GetUser($UserName) {
return array( Id => 1,
Name => $UserName,
Email => test@a.com ,
Description => My desc
);
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ;
$server->service($HTTP_RAW_POST_DATA);
?>
And the client program client.php
:
<?php
// Pull in the NuSOAP code
require_once( lib/nusoap.php );
// Create the client instance
$client = new soapclient( http://localhost/Service/service.php );
// Call the SOAP method
$result = $client->call( GetUser , array( UserName => Jim ));
// Display the result
print_r($result);
?>