Web Service Nusoap Return Error

Asked

Viewed 1,924 times

1

I’m developing a web service with Nusoap on Laravel 4.

The class I’m wearing is the 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'));
});

Client

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);
        }
    }
});

In return is bringing this mistake.

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 the right Laravel.

2 answers

2


  • You can accept the answer there on the left.

1

http://sourceforge.net/projects/nusoap/files/nusoap/

Last Update: 2011-01-13

That doesn’t exactly answer your question, but it will solve your mistake. 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. He was good once, though if you find an error with it, you will have no chance to solve but to stop using it or do it in pure PHP. I strongly recommend that if he is not doing something trivial, it is extremely likely that if you go deep hunting you will see some part of him that would need to be completely rewritten, to the point that it is worth not using it if it does not work perfectly.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.