打印

[php] 一个webservice出错的问题

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in E:\Web\iPVD\soap\test.php:26Stack trace:#0 [internal function]: SoapClient->__call('User', Array)#1 E:\Web\iPVD\soap\test.php(26): SoapClient->User('333', '2')#2 {main}  thrown in E:\Web\iPVD\soap\test.php on line 26


服务端
复制内容到剪贴板
代码:
<?php
class SoapDiscovery {
        public function __construct($class_name = '', $service_name = '') {
                $this->class_name = $class_name;
                $this->service_name = $service_name;
        }
        
        public function User($id,$token) {
                        if ($id=="1" && $token=="2"){
                                $w=0;
                        }else{
                                $w=1;
                        }
                        return $w;
        }
}
                                 
  $server = new SoapServer("SoapDiscovery.wsdl", array('soap_version'=> SOAP_1_2));
  $server->setClass("SoapDiscovery");
  $server->handle();
?>
客户端
复制内容到剪贴板
代码:
<?php
header("Content-Type: text/html; charset=utf-8");
/*
* 指定WebService路径并初始化一个WebService客户端
*/
$ws     = "http://192.168.1.23/soap/WebService.php?wsdl";
$client = new SoapClient($ws);
/*
* 获取SoapClient对象引用的服务所提供的所有方法
*/
echo("SOAP服务器提供的开放函数:");
echo('<pre>');
var_dump($client->__getFunctions());
echo('</pre>');
echo("SOAP服务器提供的Type:");
echo('<pre>');
var_dump($client->__getTypes());
echo('</pre>');
$id="333";
$token="2";
$out=$client->User($id,$token);
$datadb=$out->out;
echo(htmlspecialchars($client->__getLastRequest()));
echo('<pre>');
var_dump($out);
echo('</pre>');
?>
WSDL是用ZEND自动生成
为何出错?
@ Blog @ Ixna
要得富贵荣华,天主张,由不得我;要做仁人君子,我主张,由不得天!
@ Blog @ Ixna
要得富贵荣华,天主张,由不得我;要做仁人君子,我主张,由不得天!
很明显,不是php的bug,你看你。。。而是php解析namespace的和其它语言的稍微不同问题,说起来话长了,解决方案我有。q 我,聊。
23555455(WEB中高程Q群) 我的播客,去代码片断平台