用的PHP5的Soap,不是nusoap.两个问题
1.SoapHeader如何发送出去
我代码如下:相关疑问是注释部分$client = new SoapClient('http://127.0.0.1/server.php?WSDL);
class authentication_header {
private $username;
private $password;
public function __construct($username,$password) {
$this->username=$username;
$this->password=$password;
}
}
$auth = new authentication_header('myuser','secret');
// create authentication header values
$authvalues = new SoapVar($auth,SOAP_ENC_OBJECT,'authenticate');
// generate header
$header = new SoapHeader("myURN","authenticate",$authvalues,false,"http://schemas.xmlsoap.org/soap/actor/next");
//$client->__setSoapHeaders(array($header)); //此行的功效是否会在__call的时候传递header?
$client->soap_defencoding='utf-8';
$client->decode_utf8=false;
$client->xml_encoding = 'utf-8';$client->__call('login',array('username'=>'s','userpass'=>'f'),false,$header,$out);//此行报错Fatal error: SoapClient::__call() [<a href='function.SoapClient---call'>function.SoapClient---call</a>]: first parameter must be string or null,换成__soapCall也报同样的错误
2.以上是发送程序,请问我用php如何写接收header的程序?也就是如何让服务器端知道我发送的Header中的username和passwordrequire './test_class.php';$server = new SoapServer('./TestWSDL.wsdl');//用ZDE生成的一个wsdl
$server->setClass('CTest');
$server->handle();//如何接收username和password????
1.SoapHeader如何发送出去
我代码如下:相关疑问是注释部分$client = new SoapClient('http://127.0.0.1/server.php?WSDL);
class authentication_header {
private $username;
private $password;
public function __construct($username,$password) {
$this->username=$username;
$this->password=$password;
}
}
$auth = new authentication_header('myuser','secret');
// create authentication header values
$authvalues = new SoapVar($auth,SOAP_ENC_OBJECT,'authenticate');
// generate header
$header = new SoapHeader("myURN","authenticate",$authvalues,false,"http://schemas.xmlsoap.org/soap/actor/next");
//$client->__setSoapHeaders(array($header)); //此行的功效是否会在__call的时候传递header?
$client->soap_defencoding='utf-8';
$client->decode_utf8=false;
$client->xml_encoding = 'utf-8';$client->__call('login',array('username'=>'s','userpass'=>'f'),false,$header,$out);//此行报错Fatal error: SoapClient::__call() [<a href='function.SoapClient---call'>function.SoapClient---call</a>]: first parameter must be string or null,换成__soapCall也报同样的错误
2.以上是发送程序,请问我用php如何写接收header的程序?也就是如何让服务器端知道我发送的Header中的username和passwordrequire './test_class.php';$server = new SoapServer('./TestWSDL.wsdl');//用ZDE生成的一个wsdl
$server->setClass('CTest');
$server->handle();//如何接收username和password????
解决方案 »
- PHP分组查询生成XML
- Linux下怎么升级到php5.2版本,现在系统中默认的是php5.1.6版本
- 本机调试代码,如何取得完整的根目录路径?
- 一个头疼的显示问题```````高手请进
- Fatal error: Cannot re-assign $this in D:\php\function.php on line 40 这个解决方法,知道的请进
- php连接sql server问题
- 在线等待!!多谢了。
- php在安全性方面较之asp由那些优势?
- PHP到了生死存亡的时候了吗?
- php中打印输出echo与嵌入html代码两种的比较
- 关于循环表单重名提交更新~提问~谢谢大家
- 统计求助关键字统计?
报错的问题以及功能解决
把false改成null就行了,如下:
$client->__call('login',array('username'=>'s','userpass'=>'f'),null,$header);//顺便删除了$out