michalkortas / webservicentlm
覆盖默认 SoapClient 类,以使用 NTLM Windows 身份验证连接 Web 服务
1.0.0
2020-07-02 09:51 UTC
This package is auto-updated.
Last update: 2024-09-29 06:14:22 UTC
README
覆盖默认 SoapClient 类,以使用 NTLM Windows 身份验证连接 Web 服务
许可
MIT
通过 Composer 安装
composer require michalkortas/webservicentlm
Laravel 5.5 及更早版本
在 config/app.php 中注册新的 ServiceProvider
michalkortas\WebserviceNtlm\WebserviceNtlmProvider::class
在 config/app.php 中注册新的别名
'NtlmSoapService' => michalkortas\WebserviceNtlm\Services\NtlmSoapService::class
用法
设置凭证
只需将其添加到您的 .env 文件中
NTLM_DOMAIN="domain" NTLM_USER="user" NTLM_PASSWORD="password"
初始化连接
$client = NtlmSoapService::initClient('https://your_webservice_url'); $data = $client->webserviceMethod();
更改连接
该软件包使用 config/ntlmsoapservice.php 文件来设置域\用户凭证。如果您想使用其他凭证连接到其他 Web 服务,请在此文件中设置新的凭证类型,例如。
return [ 'default' => [ 'domain' => env('NTLM_DOMAIN', 'domain'), 'user' => env('NTLM_USER', 'user'), 'password' => env('NTLM_PASSWORD', 'password'), ], 'other_credentials' => [ 'domain' => 'domain2', 'user' => 'user2', 'password' => 'user3', ], ];
将凭证名称作为第二个 initClient() 参数添加
$client = NtlmSoapService::initClient('https://other_webservice_url', 'other_credentials'); $data = $client->webserviceMethod();
头部
如果您想向连接添加一些头部信息,只需输入
$client = NtlmSoapService::initClient('https://your_webservice_url'); $header = new \SoapHeader( 'http://schemas.xmlsoap.org/soap/envelope/', 'Header'); $client->__setSoapHeaders($header); $data = $client->webserviceMethod();
获取最后一个请求
如果您想显示最后一个请求(例如发送 XML),请检查 __getLastRequest() 方法
$client = NtlmSoapService::initClient('https://your_webservice_url'); $header = new \SoapHeader( 'http://schemas.xmlsoap.org/soap/envelope/', 'Header'); $client->__setSoapHeaders($header); $data = $client->webserviceMethod(); var_dump($client->__getLastRequest());