©
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
(PHP 5 >= 5.0.1)
Represents a SOAP header.
$namespace
, string $name
[, mixed $data
[, bool $mustunderstand
[, string $actor
]]] )$namespace
, string $name
[, mixed $data
[, bool $mustunderstand
= false
[, string $actor
]]] )[#1] voroks at logics dot net dot au [2015-07-03 12:43:36]
Example by john at jtresponse dot co dot uk does miss one important point: to be able to add attributes they must be mentioned in WSDL. If they not exist in WSDL they WILL NOT appear as attributes but rather <item><key/><value/></item> elements.
[#2] john at jtresponse dot co dot uk [2012-03-13 13:30:22]
None of the examples really do it for me.
Note: you should NOT need to hard-code any XML.
Here is an example of creating a nested header and including a parameter.
$client = new SoapClient(WSDL,array());
$auth = array(
'UserName'=>'USERNAME',
'Password'=>'PASSWORD',
'SystemId'=> array('_'=>'DATA','Param'=>'PARAM'),
);
$header = new SoapHeader('NAMESPACE','Auth',$auth,false);
$client->__setSoapHeaders($header);
Gives the following header XML:
<SOAP-ENV:Header>
<ns1:Auth>
<ns1:SystemId Param="PARAM">DATA</ns1:SystemId>
<ns1:UserName>USERNAME</ns1:UserName>
<ns1:Password>PASSWORD</ns1:Password>
</ns1:Auth>
</SOAP-ENV:Header>