nhkey / yii2-soap
PHP的默认SoapClient的包装器
1.0
2016-08-23 13:02 UTC
Requires
- ext-soap: *
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-18 19:00:57 UTC
README
此扩展是PHP中默认SoapClient的包装器。
安装
安装此扩展的最佳方式是通过 composer。
运行以下命令之一:
php composer.phar require nhkey/yii2-soap "*"
或者
"nhkey/yii2-soap": "*"
将以下内容添加到你的 composer.json 的 require 部分中。
使用方法
您需要在配置文件的 'components' 部分中添加此扩展
'components' => [ 'soapClient' => [ 'class' => \nhkey\soap\SoapClientWrapper::className(), 'url' => '<SOAP_WSDL_URL>', // SoapClient options 'options' => [ 'cache_wsdl' => WSDL_CACHE_NONE, 'debug' => true, ], // SopaClient headers, object or closure 'headers' => function() { $headers = new stdClass(); $headers->authDetails = new stdClass(); // This is node in SOAP Header where the login and password. $headers->authDetails->login = 'LOGIN'; $headers->authDetails->password = 'PASSWORD'; return $headers; } ], ... ]
现在您可以使用此扩展,例如:
try { $soap = Yii::$app->soapClient; $result = $soap->makeSmb(['arg1' => 'foo', 'arg2' => 'bar']); } catch (SoapClientWrapperException $e) { return ['request' => $soap->getLastRequest(), 'response' => $soap->getLastResponse()]; }
致谢
作者:Mikhail Mikhalev