$xpath = new DOMXPath($dom_initial);
$xpath->registerNamespace('secdsig',
'
http://www.w3.org/2000/09/xmldsig#');
$query = ".//secdsig:Signature";
$nodeset = $xpath->query($query, $dom_initial);
$sigNode = $nodeset->item(0);
if (! $dom_initial->isSameNode($sigNode)) {
$sigNode->parentNode->removeChild($sigNode);
}
$xpath_query =
'not(ancestor-or-self::node()[@soap:actor=
"urn:oasis:names:tc:ebxml-msg:action:nextMSH"]
|
ancestor-or-self::node()[@soap:actor=
"http://schemas.xmlsoap.org/soap/actor/next"])';
$arXPath = array();
$arXPath['query'] = '(.//. | .//@* |
.//namespace::*)['.$xpath_query.']';
$arXpath['namespaces'] = array();
$arXPath['namespaces']['soap'] =
'
http://schemas.xmlsoap.org/soap/envelope/';
$arXPath = NULL;
$initial_xml_data = $dom_initial->C14N(FALSE, FALSE, $arXPath);
$digest1 = base64_encode(sha1($initial_xml_data, TRUE));
echo "actual: $digest1\n";
echo "expected: JIvV28g5qiXTxPsKyO7RPsU0+JI=\n\n";