客户端代码:
<?php $client = new SoapClient(null, array('location'=>"http://192.168.1.100/test/serverSoap.php",'uri' =>"http://soap/")); echo $client->show(); ?>
服务器代码:
<?php 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服务以开启:
回复讨论(解决方案)
太粗心了,这样写
<?php 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();?>
补充下
<?php 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();?>