Nusoap return $HTTP_RAW_POST_DATA empty

Asked

Viewed 259 times

1

I’m trying to create a Webservice using the nusooap. However my return is always empty. Online is created the webservice and I can see the methods and xml (WSDL). But when trying to access via cliente.php the return is vázio.

test-server.php

require_once "php/class/nusoap-0.9.5/lib/nusoap.php";

$soap = new soap_server;

  $soap->configureWSDL('WS-WebCodeFree', 'http://www.philipsvaloriza.com.br/teste-server.php');

  $soap->wsdl->schemaTargetNamespace = 'http://www.philipsvaloriza.com.br/teste-server.php';

    $soap->register(
        'info',
        array(),
        array('x' => 'xsd:string'),
        'http://soapinterop.org/'
    );

    $soap->register(
        'post_java',
        array(),
        array('x' => 'xsd:string'),
        'http://soapinterop.org/'
    );

    $soap->register(
        'post_php',
        array(),
        array('x' => 'xsd:string'),
        'http://soapinterop.org/'
    );

    $soap->register(
        'login_user',
        array('login' => 'xsd:string','pass' => 'xsd:int'),
        array('x' => 'xsd:string'),
        'http://soapinterop.org/'
    );

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : 'teste123';
$soap->service(isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '');

function info(){
    return "WebCodeFree - Desenvolvimento Web.";
}

function post_java(){
    return "Em Breve Acesso a Postagens Java Via Serviço";
}

function post_php(){
    return "Em Breve Acesso a Postagens PHP Via Serviço";
}

function login_user($login, $senha){
    return "Seja Bem Vindo Usuário ". $login . " !!!";
}

php client.

include('lib/nusoap.php');


        $cliente = new nusoap_client('http://localhost/vinicius/thiengo/doc/projects/web-service-php-nusoap/servidor.php?wsdl');


    $result1 = $client->call('info');

    $result2 = $client->call('post_java');

    $result3 = $client->call('post_php');

    $result4 = $client->call('login_user', array('Paulo',12));

    echo $result1."<br>";
    echo $result2."<br>";
    echo $result3."<br>";
    echo $result4."<br>";

Reference: http://www.webcodefree.com.br/blog/? p=1480

  • What is the php version? 5.6?

  • Yes @rray the server is using PHP 5.6

1 answer

1

The use of $HTTP_RAW_POST_DATA is obsolete since php5.6 and removed in php7. Instead use:

$info = file_get_contents('php://input');
  • I subistitui the "$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : 'teste123'; $Soap->service(isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '');" for "$Postdata = file_get_contents('php://input'); $Soap-service(isset($Postdata);". But the return goes on. Can you tell me if the way to use the class nusoap tb changes?

  • @Lan take this one isset() of $soap->service(isset($postData))

  • I withdrew. And yet the return goes on and on. I also created a file on the server: "$file = fopen('.txt file', 'w'); fwrite($file, $Postdata);" and he created the blank file. For some reason the $Postdata variable is not receiving value.

  • @Alan tried to make the call with soup_client (native) from php?

  • No. I ran the tests only with nusoop_client. I will run a test.

Browser other questions tagged

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