您好,欢迎访问一九零五行业门户网

nusoap如何封装请求头

用php请求java的webservice接口,对方考虑到安全因素,需要在请求头包含一个验证信息
考虑到安全因素,因此需要ws的客户端在调用服务的时候,请求头需要包含一个验证信息,否则服务将不可访问。实现方式为注册一个callbackhandler,进行identifier的验证。
一直使用nusoap进行接口封装,但对于请求头验证还是第一次遇到,哪位大大能够指点下,不甚感激!!!
回复讨论(解决方案) http认证?
soapheader
soapheader这个是php扩展的,nosuap没有这个
soapheader
把服务器上的soap开启后,重新了下代码
$client = new soapclient($url); $soap_header = new soapheader($url, 'callbackhandler', 'wsadmin',false, soap_actor_next); $client->__setsoapheaders(array($soap_header)); $info = $client->__soapcall('getclassstudent', array('userid' => 1));print_r($info);
运行后,每次都报错
soapfault exception: [ns1:invalidsecurity] an error was discovered processing the header in /var/www/html/exam/lib/action/home/indexaction.class.php:264 stack trace: #0
今天终于弄好了,我想以后应该也会有人有此疑惑的,顾贴出源码,省去我这几天所浪费的时间
$xml = ' admin passwordtext ';$s = new soapheader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'callbackhandler', new soapvar($xml, xsd_anyxml), true);$client = new soapclient($wsdl);$client->__setsoapheaders(array($s));print_r($client);
其它类似信息

推荐信息