jeudi 27 août 2015

Web service not response result in client

i try test web service with nusoap and php. And here is my code:

Server.php:

    require_once ("lib/nusoap.php");
    $URL= 'http://myexample/service.php';
    $namespace = $URL.'?wsdl';

    $server = new soap_server();
    $server->configureWSDL("topUsers",$namespace);
    $server->register("getTopUser");
    $server->soap_defencoding = 'UTF-8';
    $server->decode_utf8 = false;
    $server->encode_utf8 = true;

    function getTopUser(){
        $conn = mysql_connect('localhost','root','test@123') or die(mysql_error());
    mysql_select_db('test',$conn)or die(mysql_error());
    mysql_query("SET charactor_set_results=utf8",$conn);
    mysql_query("SET NAMES 'utf8'");
        $query = mysql_query("SELECT * FROM player ORDER BY money DESC LIMIT 0,10",$conn) or die (mysql_error());
        while($row = mysql_fetch_array($query)){
            $data[] = array(
                'userid'=>$row['userid'],
                'username'=>$row['nick'],
                'money'=>$row['money']
            );
       }
        return $data;
    }
if(!isset ( $HTTP_RAW_POST_DATA ))$HTTP_RAW_POST_DATA = file_get_contents ('php://input'); 
$server -> service ( $HTTP_RAW_POST_DATA );

Client.php:

require_once("lib/nusoap.php");
$url = 'http://myexample/service.php?wsdl';
$client = new nusoap_client($url);
$reponse = $client->call('getTopUser',array());
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
//$client->decode_utf8 = false;
$err = $client->getError();
echo $err;

echo $reponse;
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

And here is result of my code:

2015-08-27 03:14:09.228293 nusoap_parser: parsed successfully, found root struct: 2 of name getTopUserResponse
2015-08-27 03:14:09.228530 nusoap_client: sent message successfully and got a(n) string
return=string(0) ""

I don't know i wrong somewhere? Somebody help me, please. Thanks!




Aucun commentaire:

Enregistrer un commentaire