|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2017-07-19 (2 years ago) ||Not enough user ratings||Total: 161 ||All time: 8,689 This week: 333|
This package can create header to set password for SOAP requests.
It takes the user name and a password and generate a header for sending a SOAP request to a server and authenticate on behalf of the given user.
The class takes an optional parameter to use digest authentication and the password be encrypted when the request is sent.
|Many Web services are provided by servers that implement the SOAP protocol.
PHP provides built-in support to sending HTTP SOAP requests to remote servers. However it does not come with direct support to enter the credentials to servers that require user authentication.
This package can create a header to set user name and password for SOAP requests to servers that require them.
How to use it
This repository contains multiple classes that may be used indepdently but for now it is easier/better to only use the WsSecurity class.
The WsSecurity class provides a static method that takes the parameters that should suffice to create your Ws-Security Username Authentication header required in your SOAP request.
Concretly, you must include this repository in your project using composer (
composer require wsdltophp/wssecurity:dev-master) then use it such as:
* @var \SoapHeader
$soapHeader = WsSecurity::createWsSecuritySoapHeader('login', 'password', true);
* Send the request
$soapClient = new \SoapClient('wsdl_url');
WsSecurity::createWsSecuritySoapHeader parameters are defined in this order
($username, $password, $passwordDigest = false, $addCreated = 0, $addExpires = 0, $returnSoapHeader = true, $mustunderstand = false, $actor = null, $usernameId = null):
- $username: your login/username
- $password: your password
- $passwordDigest: set it to
true if your password must be encrypted
- $addCreated: set it to the time you created this header using the PHP time function for example, otherwise pass 0
- $addExpires: set it to the number of seconds in which the header will expire, 0 otherwise
- $returnSoapHeader: set it to false if you want to get the \SoapVar object that is used to create the \SoapHeader object, then you'll have to use to create by yourself the \SoapHeader object
- $mustunderstand: classic option of the \SoapClient class
- $actor: classic option of the \SoapClient class
- $usernameId: the id to attach to the UsernameToken element, optional
You can run the unit tests with the following command at the root directory of this project:
Any feedback is appreciated at firstname.lastname@example.org or by creating an issue on this project.
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.