"http://soap/")); echo $client->show(); ?">
当前位置:Gxlcms > PHP教程 > php写WebService无法通信,该怎么解决

php写WebService无法通信,该怎么解决

时间:2021-07-01 10:21:17 帮助过:3人阅读

php写WebService无法通信
客户端代码:

$client = new SoapClient(null, array('location'=>"http://192.168.1.100/test/serverSoap.php",'uri' =>"http://soap/"));
echo $client->show();
?>

服务器代码:

class test{
function show(){
return 'the data you request';
}
}
function getUserInfo($name){
return 'fbbin';
}
$soap = new SoapServer(null, array('uri'=>'http://soap/','location'=>'http://localhost/test/serverSoap.php'));
$server->serClass('test');
$server->handle();
?>

运行环境用的wamp,以上两个文件都放在wamp安装目录的www/test/目录下。

操作系统window 8

打开浏览器,访问客户端文件

http://localhost/test/serverClient.php

显示错误信息如下:

我是新手啊,php刚学没几天,webservice也只是知道用来干啥的,从来没用过。麻烦诸位讲的通俗一点可不可以啊,谢谢回答。

php的soap服务以打开。
php的soap服务以开启:

------解决方案--------------------
太粗心了,这样写
    class test{
function show(){
return 'the data you request';
}
}
function getUserInfo($name){
return 'fbbin';
}
$server = new SoapServer(null, array('uri'=>'http://soap/','location'=>'http://localhost/test/serverSoap.php'));
$server->setClass('test');
$server->handle();
?>

------解决方案--------------------
补充下


class test{
function show(){
return 'the data you request';
}

function getUserInfo($name){
return 'fbbin';
}
}
$server = new SoapServer(null, array('uri'=>'http://soap/','location'=>'http://localhost/test/serverSoap.php'));
$server->setClass('test');
$server->handle();
?>

人气教程排行