use RobRichards\WsePhp\WSASoap;
use RobRichards\WsePhp\WSSESoap;
use RobRichards\WsePhp\WSSESoapServer;
use RobRichards\XMLSecLibs\XMLSecurityKey;
class MCallback extends SoapServer
{
public function handle($soap_request = null)
{
parent::handle();
$headers = $this->getHeaders();
ob_end_clean();
ob_start();
ini_set("soap.wsdl_cache_enabled", "0");
//$headers = getHeaders();
$dom = new DOMDocument();
$action = str_replace('"', '', $headers['SOAPACTION']);
//error_log($xml, 0);
$dom->loadXML($xml);
$objWSA = new WSASoap($dom);
$dom = $objWSA->getDoc();
$objWSSE = new WSSESoap($dom);
/* Sign all headers to include signing the WS-Addressing headers */
$objWSSE->signAllHeaders = true;
$objWSSE->addTimestamp();
/* create new XMLSec Key using RSA SHA-1 and type is private key */
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array(
'type' => 'private'
));
/* load the private key from file - last arg is bool if key in file (true) or is string (FALSE) */
$objKey->loadKey(PRIVATE_KEY, true);
/* Sign the message - also signs appropraite WS-Security items */
$objWSSE->signSoapDoc($objKey);
/* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
$token = $objWSSE->addBinaryToken(trim(file_get_contents(CERT_FILE)));
$objWSSE->attachTokentoSig($token);
$response = $objWSSE->saveXML();
print_r($response);
exit;
//$res = $this->formatXmlString($response);
}