triple_des(des3) 算法 - php,python 实现
wos2 WSF/PHP soap header 认证实现

PHP: Soap 通过 soap header 认证(non-wsdl 模式)

TLHL28 posted @ Mon, 30 May 2011 17:08:07 +0800 in 随笔 with tags php soap , 8330 readers

 

soap service 是 java的 axis2

soap client 是 php. = =

                 $url = "http://localhost:8000/PortalService";
                // 对应wsdl 文件定义中的targetNamespace
		$uri = "http://localhost/partalService";

		$key = "xxx";
		$pwd = "xxx";

		$options=array(
			//'soap_version'=>SOAP_1_2,
			'trace'=>1,
			//"exceptions"=>1,
			'location'=>$url,
			'uri'=>$uri,
		);

		$auth_header = array(
			'user'=>$key,
			'password'=>$pwd,
		);
                // 下面的RequestSOAPHeader 对应 wsdl 定义里面的 <xsd:element name="RequestSOAPHeader">.....
		$authvalues = new SoapVar($auth_header, SOAP_ENC_OBJECT,"RequestSOAPHeader",$uri);  
		$header = new SoapHeader($uri, 'RequestSOAPHeader', $authvalues);

		$api = new SoapClient(null,$options);
		$api->__setSoapHeaders(array($header));
		
                // 在调用 java axis2 soap 的使用要这么定义, 不然会变成 <param0><item>xxx</item><value>xxx</value></param0>
                // 所以会报错. 用一下定义生成的就是这样的格式: <user>asdf</user>
		$p = array(
			new SoapParam("asdf",'user'),
			new SoapParam(1,'password'),
		);
		try {
			$call="Login";
			$result = $api->__soapCall($call,$p);
			print_r($result);
		} catch(SoapFault $e) {
			if(1) {
				var_dump($api->__getLastRequestHeaders());
				var_dump($api->__getLastRequest());
				var_dump($api->__getLastResponseHeaders());
				var_dump($api->__getLastResponse());
				echo $e->getMessage();
			}
		}

 

51aijianakng said:
Fri, 24 May 2013 10:23:20 +0800

刚学这个不是很懂,要是写详细点就好了,不知道能不能在实例话客户端的时候就传一个值,就想构造函数一样


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter