0
我是新角落以及編程。我試圖創建一個基於nusoap和php的web服務,因此它將mysql數據庫中的一些值傳遞出去。 我已經瀏覽了很多網站(包括堆棧溢出答案),我發現了一些我已經嘗試但尚未成功的解決方案。出於某種原因,當我讓客戶端訪問服務時,它總是空的。經過一天看這個我只看到字母現在...Php nusoap不通過內容
如果有人可以提供一種解決方案,我將不勝感激。謝謝!
服務器端
<?php
include 'nusoap.php';
$server=new nusoap_server();
$server->configureWSDL("demo"."urn:demo");
$server->register(
'gamedata',
array(),
array("estadio"=>'xsd:string',
"nome"=>'xsd:string',
)
);
function gamedata(){
$con=mysql_connect('127.0.0.1:3306', 'root', '') or die ("Erro ao conectar...");
mysql_select_db("testar",$con) or die ("Erro ao seleccionar DB...");
$queryforestadio="SELECT nome,cidade FROM estadio";
//$queryforjogos = "SELECT data, id_selecao1, id_selecao2 FROM jogo";
while($resultestadio = mysql_fetch_array($queryforestadio)){
$estadios[] = array('nome'=>$resultestadio['nome'],
'cidade'=>$resultestadio['cidade'],
);
echo "Message from function: ".$estadios['nome']['cidade'];
}
return $estadios;
}
if (!isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA =file_get_contents('php://input');
$server->service($HTTP_RAW_POST_DATA);
?>
客戶端
<?php
require('nusoap.php');
$client = new nusoap_client('http://localhost:8048/webservice/index.php');
$response= $client->call('gamedata');
$r = $response;
$count = count($r);
for($i=0; $i<=$count-1;$i++){
echo "This is name: ".$r[$i]['nome'];
echo "This is city: ".$r[$i]['cidade'];
}