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自动生成
为何出错?