Kashif Roshen Kashif Roshen - 4 months ago 33
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 :)


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