RobRichards\WsePhp\WSASoap::addMessageID PHP Method

addMessageID() public method

public addMessageID ( $id = null )
    public function addMessageID($id = null)
    {
        /* Add the WSA MessageID or return existing ID */
        if (!is_null($this->messageID)) {
            return $this->messageID;
        }
        if (empty($id)) {
            $id = XMLSecurityDSig::generateGUID('uuid:');
        }
        $header = $this->locateHeader();
        $nodeID = $this->soapDoc->createElementNS(self::WSANS, self::WSAPFX . ':MessageID', $id);
        $header->appendChild($nodeID);
        $this->messageID = $id;
    }

Usage Example

Example #1
0
 function __doRequest($request, $location, $saction, $version)
 {
     $dom = new DOMDocument();
     $dom->loadXML($request);
     $objWSA = new WSASoap($dom);
     $objWSA->addAction($saction);
     $objWSA->addTo($location);
     $objWSA->addMessageID();
     $objWSA->addReplyTo();
     $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(file_get_contents(CERT_FILE));
     $objWSSE->attachTokentoSig($token);
     $request = $objWSSE->saveXML();
     return parent::__doRequest($request, $location, $saction, $version);
 }