traff-ik/amphp-async-soap

This package is abandoned and no longer maintained. The author suggests using the traffaret/amphp-async-soap package instead.

Async soap requests with amphp

v1.0.1 2020-11-16 20:38 UTC

This package is auto-updated.

Last update: 2024-04-03 18:07:20 UTC


README

GitHub Actions Test Coverage Maintainability GitHub release (latest SemVer including pre-releases)

async-soap

Amphp soap async

use Amp\Http\Client\HttpClientBuilder;
use Traff\Soap\Options;
use Traff\Soap\SoapTransportBuilder;
use Traff\Soap\Wsdl\WsdlUrlFactory;

$http_client = HttpClientBuilder::buildDefault();
$options = (new Options())
    ->withSoapVersion(\SOAP_1_1)
    ->withConnectionTimeout(20);

$wsdl = yield (new WsdlUrlFactory())
    ->createWsdl('https://cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL', null, $http_client)
    ->toString();

$soap_transport = (new SoapTransportBuilder())
    ->withHttpClient($http_client)
    ->withWsdl($wsdl)
    ->withOptions($options)
    ->build();

$result = yield $soap_transport->callAsync('GetCursOnDate', [['On_date' => (new \DateTime('now'))->format('Y-m-d')]]);

// Or

$result = yield $soap_transport->GetCursOnDate(['On_date' => (new \DateTime('now'))->format('Y-m-d')]);