Hi,
I am trying to create the soap request using this library. I need to create digitally signing the XML request (i.e. generate the
envelope the digest value is expected to be the hash of the message generated
after using the certificates.). For that I am writing below code:
<?php
.
.
.
.
</ws:doc>
</soapenv:Body>
</soapenv:Envelope>';
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->preserveWhiteSpace = false;
$doc->loadXML($xml);
$objDSig = new XMLSecurityDSig(FALSE);
$objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
//$objDSig->addObject($doc->documentElement);
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
/* load private key */
$objKey->loadKey(dirname(__FILE__) . '/privkey.pem', TRUE);
$objDSig->sign($objKey);
/* Add associated public key */
$objDSig->add509Cert(file_get_contents(dirname(__FILE__) . '/mycert.pem'));
$objDSig->appendSignature($doc->firstChild->firstChild->firstChild);
$request = $doc->saveXML();
?>
But when I trying to send this request I am getting following error in response:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<env:Fault>
<faultcode>XML Parse Error</faultcode>
<faultstring>Hash values do not match.</faultstring>
<faultactor>ADP Secure Web Services Gateway</faultactor></env:Fault></env:Body></env:Envelope>
Anybody out there, who could please help me with what is wrong here?
Regards,
Milind