I'm developing a web service with NuSOAP in Laravel 4.
The class I'm using is link
Server
Route::any('ws/server', function()
{
$server = new \soap_server;
$server->configureWSDL('server.hello','urn:server.hello', Request::url());
$server->wsdl->schemaTargetNamespace = 'urn:server.hello';
$server->register('hello',
array('name' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:server.hello',
'urn:server.hello#hello',
'rpc',
'encoded',
'Retorna o nome'
);
function hello($name)
{
return 'Hello '.$name;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
return Response::make($server->service($HTTP_RAW_POST_DATA), 200, array('Content-Type' => 'text/xml; charset=ISO-8859-1'));
});
Customer
Route::get('ws/client/hello', function()
{
$client = new \nusoap_client('http://localhost/teste_laravel/public/ws/server?wsdl', true);
$err = $client->getError();
if ($err)
{
echo "Erro no construtor<pre>".$err."</pre>";
}
$result = $client->call('hello',array('Renato'));
if ($client->fault)
{
echo "Falha<pre>".print_r($result)."</pre>";
}
else
{
$err = $client->getError();
if ($err)
{
echo "Erro<pre>".print_r($err)."</pre>";
}
else
{
print_r($result);
}
}
});
No return is bringing this error.
Array ( [faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => error in msg parsing: xml was empty, didn't parse! [detail] => ) Falha 1
When I make the server with pure PHP and the client with Laravel is right.