/amphp-async-soap

Amphp soap async

Primary LanguagePHPMIT LicenseMIT

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')]);