php写WebService无法通信

WBOY
Release: 2016-06-23 14:01:01
Original
996 people have browsed it

客户端代码:

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

服务器代码:
<?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();?>
Copy after login

运行环境用的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();?>
Copy after login

补充下

<?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();?>
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