Skip to content

Instantly share code, notes, and snippets.

@jjcodes78
Last active April 1, 2017 06:48
Show Gist options
  • Save jjcodes78/5cc0a50df69ace58d1b7c93944275661 to your computer and use it in GitHub Desktop.
Save jjcodes78/5cc0a50df69ace58d1b7c93944275661 to your computer and use it in GitHub Desktop.
namespace SoapAuth
use SoapHeader;
use stdClass;
use SoapVar;
class WsseAuthHeader extends SoapHeader {
private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
// Não é obrigatório - It's not required
// private $wsu_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
function __construct($user, $pass) {
$auth = new stdClass();
$auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$username_token = new stdClass();
$username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
$security_sv = new SoapVar(
new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns
);
parent::__construct($this->wss_ns, 'Security', $security_sv, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment