wsdltophp/wssecurity
Composer 安装命令:
composer require wsdltophp/wssecurity
包简介
Allows to easily add Ws Security header to a SOAP Request
README 文档
README
WsSecurity adds the WSSE authentication header to your SOAP request
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) then use it such as:
use WsdlToPhp\WsSecurity\WsSecurity; /** * @var \SoapHeader */ $soapHeader = WsSecurity::createWsSecuritySoapHeader('login', 'password', true); /** * Send the request */ $soapClient = new \SoapClient('wsdl_url'); $soapClient->__setSoapHeaders($soapHeader); $soapClient->__soapCall('echoVoid', []);
The WsSecurity::createWsSecuritySoapHeader parameters are defined in this order ($username, $password, $passwordDigest = false, $addCreated = 0, $addExpires = 0, $returnSoapHeader = true, $mustunderstand = false, $actor = null, $usernameId = null, $addNonce = true):
- $username: your login/username
- $password: your password
- $passwordDigest: set it to
trueif 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
- $addNonce: true by default, if true, it adds the nonce element to the header, if false it does not add the nonce element to the header
Alternative usage
Create an instance of the Security class
use WsdlToPhp\WsSecurity\WsSecurity; $wsSecurity = new WsSecurity('login', 'password', true, /*$addCreated*/ time()); // access its properties to alter them $wsSecurity->getSecurity()->getTimestamp()->setAttribute('wsu:Id', 'AnyRequestValue'); // Get the SoapHeader $header = $security->getSoapHeader($returnSoapHeader = true, $mustunderstand = false, $actor = null);
Testing using Docker
Thanks to the Docker image of phpfarm, tests can be run locally under any PHP version using the cli:
- php-7.4
First of all, you need to create your container which you can do using docker-compose by running the below command line from the root directory of the project:
$ docker-compose up -d --build
You then have a container named ws_security in which you can run composer commands and php cli commands such as:
# install deps in container (using update ensure it does use the composer.lock file if there is any) $ docker exec -it ws_security php /usr/bin/composer update # run tests in container $ docker exec -it ws_security php -dmemory_limit=-1 vendor/bin/phpunit
FAQ
If you have a question, feel free to create an issue.
License
The MIT License (MIT). Please see License File for more information.
wsdltophp/wssecurity 适用场景与选型建议
wsdltophp/wssecurity 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 881.42k 次下载、GitHub Stars 达 40, 最近一次更新时间为 2015 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「soap」 「wsse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wsdltophp/wssecurity 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wsdltophp/wssecurity 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wsdltophp/wssecurity 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
A PHP client for the Salesforce SOAP API
Guzzle plugin to manage WSSE authentication
Buzz plugin to manage WSSE authentication
A Yii2 component for working with TurboSMS.ua SOAP service
Zend Framework 1 Soap package
统计信息
- 总下载量: 881.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 42
- 点击次数: 24
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-07