src/InsuranceCompany/OZK/SOAP/Subscriber/SoapActionSubscriber.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\InsuranceCompany\OZK\SOAP\Subscriber;
  3. use App\SoapClient\Event\RequestEvent;
  4. use Soap\Engine\HttpBinding\SoapRequest;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class SoapActionSubscriber implements EventSubscriberInterface
  7. {
  8.     const SOAP_ACTION_PREFIX 'http://brokWS.WebInsOZK.scon.com/BrokWS23/';
  9.     public function onRequest(RequestEvent $event): void
  10.     {
  11.         $request $event->getRequest();
  12.         if ($request->getAction() === '' && $request->isSOAP11()) {
  13.             $action = static::SOAP_ACTION_PREFIX $event->getMethod() . 'Request';
  14.             $event->setRequest(new SoapRequest(
  15.                 $request->getRequest(),
  16.                 $request->getLocation(),
  17.                 $action,
  18.                 $request->getVersion(),
  19.                 $request->getOneWay(),
  20.             ));
  21.         }
  22.     }
  23.     /**
  24.      * @inheritDoc
  25.      * @noinspection PhpArrayShapeAttributeCanBeAddedInspection
  26.      */
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         return [
  30.             RequestEvent::class => 'onRequest',
  31.         ];
  32.     }
  33. }