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