php无wsdl webservice服务用法
服务端:
<?php
class test
{
function add($a,$b)
{
return $a+$b;
}
}
function getUserInfo($name)
{
return 'fbbin';
}
//实例化的参数手册上面有,这个是没有使用wsdl的,所以第一个参数为null,如果有使用wsdl,那么第一个参数就是这个wsdl文件的地址。
$server = new SoapServer(null, array('uri' =>'http://soap/','location'=>'http://61.160.96.114.:8000/servplat/comm/serverSoap.php'));
$server->setClass('test');
$server->handle();
?>
客户端:
<?php
try {
$soap = new SoapClient(null, array(
//'location'=>'http://localhost:8000/servplat/comm/serverSoap.php',
'location'=>'http://61.160.96.114:8000/servplat/comm/serverSoap.php',
'uri' =>'http://soap/'
));
echo $soap->add(100,200);
} catch (SoapFault $fault){
echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
}
?>
以上程序在异地服务器上调试成功。(已增加数据库操作的例子,代码已上传本站文件service20160729.rar)
更多相关文章
- 关注:PHP文件目录和文件本身的操作
- php exec文件从终端运行,而不是从浏览器运行
- log4php将不同级别的日志打印到不同的日志文件中
- PHP - 在外部服务器上读取文件?
- 仅在LARAVEL或AJAX中提交表单时,无需用户身份验证即可将文件上载
- PHP ZipArchive 实现压缩解压Zip文件
- 纯php文件不加结束标记的好处
- 大文件从指定行开始读取
- 找不到go-pear。bat文件PHP 5.5 Windows 7。