PHP 8.0.26 Released!

La clase SoapHeader

(PHP 5, PHP 7, PHP 8)


Representa un SOAP header.

Sinopsis de la Clase

class SoapHeader {
/* Métodos */
    string $namespace,
    string $name,
    mixed $data = ?,
    bool $mustunderstand = ?,
    string $actor = ?

Tabla de contenidos

add a note

User Contributed Notes 4 notes

john at jtresponse dot co dot uk
10 years ago
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(
        'SystemId'=> array('_'=>'DATA','Param'=>'PARAM'),
  $header = new SoapHeader('NAMESPACE','Auth',$auth,false);

Gives the following header XML:

      <ns1:SystemId Param="PARAM">DATA</ns1:SystemId>
ericvaneldik at gmail dot com
3 years ago
If you want to create an soap header wihtout namespace and without an item key value setup, you can use SoapVar

To get this:

you can use this php code:
= new SoapVar('<IdentityHeader><SessionID>123456789</SessionID></IdentityHeader>',
$header = new SoapHeader('','RequestParams',
abdul dot rashid at paytabs dot co
6 years ago
Just to add some note regarding his john at jtresponse dot co dot uk

In PHP you can try following code to avoid the <item><key/>

$Auth = new stdClass();
$Auth->SystemId = "DATA";
$Auth->UserName = "USERNAME";
$Auth->Password = "PASSWORD";

$header = new SoapHeader('NAMESPACE','Auth',$Auth,false);

voroks at logics dot net dot au
7 years ago
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.
To Top