1
I’m creating a Webservice in the Laravel with the library Noiselabs.
Route::any('x/ws/hello', function(){
$server = new \soap_server;
$server->configureWSDL('server.hello', 'urn:server.hello');
$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;
}
// requisição para uso do serviço
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
});
So far so good.
Only when I try to show the generated XML with ? wsdl at the end of the URL it gives a problem. Generates a generated XML HTML.
I thought it could be the debug I’m using with Laravel, but I put false in the app.php and also continued the same way.
When I do with pure PHP it worked.
My client is this way.
Route::get('x/client/hello', function(){
// criação de uma instância do cliente
$client = new \nusoap_client('http://localhost/registro_aplicativos/public/x/ws/hello?wsdl', true);
// verifica se ocorreu erro na criação do objeto
$result = $client->call('hello', array('Renato Araujo'));
// exibe o resultado
var_dump($result);
echo '<h2>Requisição</h2>';
echo '<pre>' . htmlspecialchars($client->request) . '</pre>';
echo '<h2>Resposta</h2>';
echo '<pre>' . htmlspecialchars($client->response) . '</pre>';
// Exibe mensagens para debug
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str) . '</pre>';
});
I did what you said, but it still didn’t work.
– renatomaraujo