Created
April 20, 2017 12:08
-
-
Save rgarrigue/a72b23d7e1a0b0aa30882d1deb3bd026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSoapHeader($login, $password) { | |
$wssWssecuritySecextNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'; | |
$wssWssecurityUtilityNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'; | |
$token = new stdClass(); | |
$token->Username = new SoapVar( | |
$login, | |
XSD_STRING, | |
null, | |
null, | |
null, | |
$wssWssecuritySecextNamespace); | |
$token->Password = new SoapVar( | |
$password, | |
XSD_STRING, | |
null, | |
null, | |
null, | |
$wssWssecuritySecextNamespace); | |
$token->Nonce = new SoapVar( | |
base64_encode(pack('H*', mt_rand())), | |
XSD_BASE64BINARY, | |
null, | |
null, | |
null, | |
$wssWssecuritySecextNamespace); | |
$token->Created = new SoapVar( | |
gmdate('Y-m-d\TH:i:s\Z'), | |
XSD_DATETIME, | |
null, | |
null, | |
null, | |
$wssWssecurityUtilityNamespace); | |
$data = new stdClass(); | |
$data->UsernameToken = new SoapVar( | |
$token, | |
SOAP_ENC_OBJECT, | |
null, | |
null, | |
null, | |
$wssWssecuritySecextNamespace); | |
$soapHeader = new SoapHeader( | |
$wssWssecuritySecextNamespace, | |
'Security', | |
$data, | |
true); | |
return $soapHeader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment