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

WBOY
Release: 2016-06-13 11:50:34
Original
1070 people have browsed it

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

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

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

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

操作系统window 8

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

http://localhost/test/serverClient.php

显示错误信息如下:

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

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

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

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!