Estou desenvolvendo um web service com NuSOAP no Laravel 4.
A classe que eu estou usando é a https://github.com/noiselabs/NoiselabsNuSOAPBundle
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'));
});
Cliente
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 retorno tá trazendo esse erro.
Array ( [faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => error in msg parsing: xml was empty, didn't parse! [detail] => ) Falha 1
Quando faço o server com PHP puro e o cliente com Laravel da certo.