Re: [SOAP] WS-Security headers in PHP::SOAP and PEAR::SOAP
| From: | Peter De Vries | Date: | Mon, 17 Apr 2006 20:02:26 +0000 |
| Subject: | Re: [SOAP] WS-Security headers in PHP::SOAP and PEAR::SOAP | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-2208@lists.php.net to get a copy of this message | ||
> Thanks Adam, that does the job. Recap:
> If you need a SOAP header looking like this...
>
> <nsx:Security>
> <nsx:UsernameToken>
> <nsx:Username>MYUSERNAME</nsx:Username>
> <nsx:Password>MYPASSWORD</nsx:Password>
> </nsx:UsernameToken>
> </nsx:Security>
>
> ...get it like this:
>
> // Define WSSE_URL (converted to nsx:) as your namespace pointer
> class UPCombo {
> private $Username;
> private $Password;
> public function __construct($NewUsername, $NewPassword) {
> $this->Username = new SoapVar($NewUsername, XSD_STRING,
> null, null,
> 'Username', WSSE_URL);
> $this->Password = new SoapVar($NewPassword, XSD_STRING,
> null, null,
> 'Password', WSSE_URL);
> }
> }
>
> class WSSE_UsernameToken {
> private $UsernameToken;
> public function __construct($NewUPCombo) {
> $this->UsernameToken = new SoapVar($NewUPCombo, SOAP_ENC_OBJECT,
> null, null,
> 'UsernameToken', WSSE_URL);
> }
> }
>
> $mySoapHeader_NameSpace = WSSE_URL;
> $mySoapHeader_Name = "Security";
> $myUPCombo = new UPCombo('MYUSERNAME', 'MYPASSWORD');
> $mySoapHeader_Data = new WSSE_UsernameToken($myUPCombo);
> $mySoapHeader_MustUnderstand = true;
>
> $mySoapHeader = new SoapHeader($mySoapHeader_NameSpace,
> $mySoapHeader_Name,
> $mySoapHeader_Data,
> $mySoapHeader_MustUnderstand);
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com