theiconic/ntlm-soap

使用NTLM认证的PHP库,用于消费SOAP网络服务

v2.3.0 2024-05-03 05:37 UTC

This package is auto-updated.

Last update: 2024-09-03 08:24:27 UTC


README

Maintainability Test Coverage Build Status Latest Stable Version Total Downloads License

这个轻量级PHP库的目的是提供一个简单方便的方式与使用NTLM认证协议的SOAP服务进行通信。

示例

使用本地WSDL文件

<?php

use TheIconic\NtlmSoap\Client\NtlmSoap;
use GuzzleHttp\Client;

$client = new Client();

$soapClient = new NtlmSoap(
    $client,
    null,
    [
        'username' => 'your-username',
        'password' => 'your-password',
        'wsdl' => 'path-of-your-local-wsdl-file',
        'wsdl_options' => [
            'location' => 'http://my-location.com',
            'cache_wsdl' => WSDL_CACHE_NONE,
        ],
    ]
);

$response = $soapClient->soapMethod([
    'methodParameter' => null,
]);

为了使用远程WSDL定义,你需要一个文件系统缓存适配器。客户端将一次性获取WSDL并将其存储在你的文件系统中。示例

<?php

use Symfony\Component\Filesystem\Filesystem;
use TheIconic\NtlmSoap\Cache\FilesystemCache;
use TheIconic\NtlmSoap\Client\NtlmSoap;
use GuzzleHttp\Client;

$cacheRootDir = __DIR__.'/cache';
$defaultTtl = 3600; // cache the WSDL files for 1 hour

$client = new Client();
$cache = new FilesystemCache(new Filesystem(), $cacheRootDir, $defaultTtl);

$soapClient = new NtlmSoap(
    $client,
    $cache,
    [
        'username' => 'your-username',
        'password' => 'your-password',
        'wsdl' => 'http://myurl.com/remote/wsdl',
    ]
);

$response = $soapClient->soapMethod();