diff --git a/SignedSoapClient.php b/SignedSoapClient.php index e923fbf..97427a7 100644 --- a/SignedSoapClient.php +++ b/SignedSoapClient.php @@ -218,9 +218,12 @@ function __doRequest($request, $location, $action, $version) $xp->registerNamespace('SOAP-ENV', self::SOAP_NS); // find or create SoapHeader - $headernode = $xp->query('/SOAP-ENV:Envelope/SOAP-ENV:Header')->item(0); - if (!$headernode) + $headernode = $xp->query('/SOAP-ENV:Envelope/SOAP-ENV:Header')->item(0); + $bodynode = $xp->query('/SOAP-ENV:Envelope/SOAP-ENV:Body')->item(0); + + if(!$headernode){ $headernode = $dom->documentElement->insertBefore($dom->createElementNS(self::SOAP_NS, 'SOAP-ENV:Header'), $bodynode); + } /** * mark SOAP-ENV:Body with wsu:Id for signing @@ -228,7 +231,6 @@ function __doRequest($request, $location, $action, $version) * >> if you want to sign other elements - mark them on this step and provide id's on the later step * */ - $bodynode = $xp->query('/SOAP-ENV:Envelope/SOAP-ENV:Body')->item(0); $bodynode->setAttributeNS(self::WSU_NS, 'wsu:Id', 'reqBody'); // prepare Security element