Kashif Roshen Kashif Roshen - 1 year ago 95
PHP Question

How to change the default soap header?

I am using this code to set the header.

$root = new \SimpleXMLElement('<S:Header/>');

and I get this error.

SimpleXMLElement::__construct(): namespace error : Namespace prefix S on Header is not defined.

Does anybody know How to solve this? :/ Thanks in advance :)

Answer Source

You need to define namespace for prefix S.

$root = new SimpleXMLElement('<S:Header></S:Header>', LIBXML_NOERROR, false, 'S', true);
//add namespace attribute into root element

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download