From 0a576e987cafd9f66a5f163781f118253cefab25 Mon Sep 17 00:00:00 2001 From: Christof Verhoeven Date: Wed, 21 Mar 2018 16:51:37 +0100 Subject: [PATCH] $bodynode must be defined before inserting new header --- SignedSoapClient.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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