Re: [SOAP] WS-Security headers in PHP::SOAP and PEAR::SOAP
| From: | Adam Maccabee Trachtenberg | Date: | Sat, 15 Apr 2006 02:10:27 +0000 |
| Subject: | Re: [SOAP] WS-Security headers in PHP::SOAP and PEAR::SOAP | ||
| References: | 1 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-2203@lists.php.net to get a copy of this message | ||
On Fri, 14 Apr 2006, Peter De Vries wrote:
> This adds the UsernameToken tags BUT for some strange reason, although I
> specify the namespace, it does not add it to the tags. (So it still doesn't
> work...)
> What am I missing here?!
Cut and paste isn't working so well right now, but try something such
as this:
-adam
define ('WSSE_URL', 'wsse');
define ('WSDL_URL', './eBaySvc.wsdl');
define ('TMT_API_USERNAME', 'x');
define ('TMT_API_PASSWORD', 'y');
class UPCombo {
private $Username;
private $Password;
public function __construct($NewUsername, $NewPassword) {
$this->Username = $NewUsername;
$this->Password = $NewPassword;
}
}
//(But just using the UPCombo class doesn't do it,
// for the UsernameToken tags to appear we need this:)
class UPToken {
private $UsernameToken;
public function __construct($NewUPCombo) {
$this->UsernameToken = new SoapVar($NewUPCombo, SOAP_ENC_OBJECT,
null, null, 'UsernameToken', WSSE_URL);
}
}
$kaeUsername = new SoapVar(TMT_API_USERNAME, XSD_STRING,
null, null, 'Username', WSSE_URL);
$kaePassword = new SoapVar(TMT_API_PASSWORD, XSD_STRING,
null, null, 'Password', WSSE_URL);
$kaeUPCombo = new UPCombo($kaeUsername, $kaePassword);
$kaeUsernameToken = new UPToken($kaeUPCombo);
$kaeSoapHeader_NameSpace = WSSE_URL;
$kaeSoapHeader_Name = "Security";
$kaeSoapHeader_Data = $kaeUsernameToken;
$kaeSoapHeader_MustUnderstand = true;
$kaeSoapHeader = new SoapHeader($kaeSoapHeader_NameSpace,
$kaeSoapHeader_Name,
$kaeSoapHeader_Data,
$kaeSoapHeader_MustUnderstand);
//WSSE_URL is http://schemas.xmlsoap.org/ws/2003/06/secext
$kaeSoapClient_WsdlUrl = WSDL_URL;
$kaeSoapClient_Options = array('trace' => 1, 'exceptions' => 0);
try {
$kaeSoapClient = new SoapClient($kaeSoapClient_WsdlUrl,
$kaeSoapClient_Options);
$x = $kaeSoapClient->__soapCall('GetUser', array(), null,
$kaeSoapHeader);
} catch (Exception $e) {
}
print_r($kaeSoapClient->__getLastRequest());
?>
--
adam@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!