Error in web service return NuSOAP

1

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.

    
asked by anonymous 10.02.2014 / 19:20

2 answers

2

I solved it this way.

$rawPostData = file_get_contents("php://input");
return Response::make($server->service($rawPostData), 200, array('Content-Type' => 'text/xml; charset=ISO-8859-1'));

link

    
12.02.2014 / 11:26
1
  

link

     

Last Update: 2011-01-13

This does not exactly answer your question, but it will resolve your error. In the past, when I had to work with RESTService in PHP, I used Nusoap because it was the best documented and many references cited it. But what I came to realize in practice is that it was already very useful in ancient times, but PHP evolved and other libraries evolved faster.

Nusoap is basically a project that stopped in time . It has already been good, but if you find an error with it, you will have no chance to solve it except to stop using it or to make pure PHP . I strongly recommend that if it is not doing something trivial, it is extremely likely that if you go deep hunting you will see some part of it that would need to be completely rewritten, so that it is worth it not to use it if it does not work perfectly. / p>

This question does not exactly answer your problem, but it certainly will avoid a lot of headaches.

    
10.02.2014 / 22:16