<?php
namespace App\InsuranceCompany\OZK\SOAP\Subscriber;
use App\SoapClient\Event\RequestEvent;
use Soap\Engine\HttpBinding\SoapRequest;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SoapActionSubscriber implements EventSubscriberInterface
{
const SOAP_ACTION_PREFIX = 'http://brokWS.WebInsOZK.scon.com/BrokWS23/';
public function onRequest(RequestEvent $event): void
{
$request = $event->getRequest();
if ($request->getAction() === '' && $request->isSOAP11()) {
$action = static::SOAP_ACTION_PREFIX . $event->getMethod() . 'Request';
$event->setRequest(new SoapRequest(
$request->getRequest(),
$request->getLocation(),
$action,
$request->getVersion(),
$request->getOneWay(),
));
}
}
/**
* @inheritDoc
* @noinspection PhpArrayShapeAttributeCanBeAddedInspection
*/
public static function getSubscribedEvents(): array
{
return [
RequestEvent::class => 'onRequest',
];
}
}