第一次用php写webservice遇到一个很奇怪的问题,详细请看内容,有代码
1.服务器端代码(service):
<?php
require_once "../views/config.inc"; // 只要加上一个就报错,用include也一样,其中config.inc 文件很简单加上就报错
$soap = new SoapServer(null,array('uri'=>"http://xxxxxx.com.cn/",'encoding'=>'UTF-8'));
$soap->setClass('user');
$soap->handle();
class user
{
protected $Rolse=array();
public function getRoles($UserName,$Password)
{
return $UserName.$Password;
}
}
?>
<?php
$roles=array();
try
{
$client = @new SoapClient(null,
array('location' =>"http://localhost/models/userInfo.php",'trace'=>1,'encoding'=>'UTF-8','uri' => "http://xxxxxx.com.cn")
);
$roles=$client->getRoles('test','12345678');
print_r($roles);
}
catch (SoapFault $fault)
{
echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
}
?>
<?php
global $conf;
$conf['DBUSER']='root';
$conf['DBPWD']='';
$conf['DBHOST']='localhost';
?>
<?php以 ANSI 保存
global $conf;
$conf['DBUSER']='root';
$conf['DBPWD']='';
$conf['DBHOST']='localhost';