php设置SoapHeader

使用php 设置soapHeader时要如下进行,不然发出去的包会变成类似“user23107720”的格式:

 $auth_header = array( 'user'=>$key, 'password'=>$pwd );
 // 下面的RequestSOAPHeader 对应 wsdl 定义里面的 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));

你可能感兴趣的:(php)