nusoap如何返回数组?
我编写的 server.php 如下:
require_once("lib/nusoap.php");
require_once("connect.php");
$server = new soap_server;
$server->configureWSDL('server', 'urn:RM');
$server->wsdl->addComplexType(
'game',
'complexType',
'struct',
'all',
'',
array(
'eventId'=>array('name'=>'eventId','type'=>'xsd:int'),
'eventName'=>array('name'=>'eventName','type'=>'xsd:string'))
);
$server->register('gamelist',
array('id'=>'xsd:int'),
array('return'=>'tns:game'),
'urn:RM',
'urn:RM#gamelist',
'rpc',
'encoded',
'Get Games Info');
function gamelist($id){
$query="select eventId, eventName from jos_games where parentId='$id'";
$rs=mysql_query($query);
$game=array();
while($row=mysql_fetch_assoc($rs)){
$game[]= $row;
}
//print_r($game);
return $game;
}
$HTTPRAW_POST_DATA = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA:"";
$server->service($HTTP_RAW_POST_DATA);
client.php 如下:
require_once("lib/nusoap.php");
$client = new nusoap_client('http://sonia.ecisoft.com/soap/server.php');
if($err=$client->getError()){
echo 'Error:'.$err;
}
$id=1;
$return = $client->call('gamelist', array('id'=>$id));
print_r($return);
我无法从 client.php 获得返回。我想列出 eventId、eventName 的行。 请帮助我,谢谢。
I write server.php as below:
require_once("lib/nusoap.php");
require_once("connect.php");
$server = new soap_server;
$server->configureWSDL('server', 'urn:RM');
$server->wsdl->addComplexType(
'game',
'complexType',
'struct',
'all',
'',
array(
'eventId'=>array('name'=>'eventId','type'=>'xsd:int'),
'eventName'=>array('name'=>'eventName','type'=>'xsd:string'))
);
$server->register('gamelist',
array('id'=>'xsd:int'),
array('return'=>'tns:game'),
'urn:RM',
'urn:RM#gamelist',
'rpc',
'encoded',
'Get Games Info');
function gamelist($id){
$query="select eventId, eventName from jos_games where parentId='$id'";
$rs=mysql_query($query);
$game=array();
while($row=mysql_fetch_assoc($rs)){
$game[]= $row;
}
//print_r($game);
return $game;
}
$HTTPRAW_POST_DATA = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA:"";
$server->service($HTTP_RAW_POST_DATA);
client.php as below:
require_once("lib/nusoap.php");
$client = new nusoap_client('http://sonia.ecisoft.com/soap/server.php');
if($err=$client->getError()){
echo 'Error:'.$err;
}
$id=1;
$return = $client->call('gamelist', array('id'=>$id));
print_r($return);
I can't get return from client.php. I want to list rows of eventId, eventName.
Please help me, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为PHP类型应该是“数组”。更改以下内容应该有效。
函数gamelist的返回值应该是这样的:
I think the PHP type should be "array". Changing the following, should work.
The return value of function gamelist should be like this:
添加复杂类型的列表Array
);
注册功能
)
Add Complex type of list Array
);
Register Function
)