hengebytes/soap-core-async-bundle

Symfony bundle for using http client as soap async client

v1.0.1 2025-04-04 10:08 UTC

This package is auto-updated.

Last update: 2025-04-04 10:10:11 UTC


README

Latest Stable Version Total Downloads License

This bundle provides a way to filter the response of async web services core bundle.

Add the bundle to your Kernel

// config/bundles.php
return [
    // ...
    Hengebytes\SoapCoreAsyncBundle\HBSoapCoreAsyncBundle::class => ['all' => true],
];

Usage

If you need some custom SOAP headers, you can add it to the request with middleware.

// src/Middleware/CustomSoapHeaderMiddleware.php
namespace App\Middleware;

use Hengebytes\SettingBundle\Interfaces\SettingHandlerInterface;
use Hengebytes\WebserviceCoreAsyncBundle\Middleware\RequestModifierInterface;
use Hengebytes\WebserviceCoreAsyncBundle\Request\WSRequest;
use Soap\Xml\Builder\SoapHeader;
use function VeeWee\Xml\Dom\Builder\children;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Builder\value;

readonly class SoapHeaderRequestModifier implements RequestModifierInterface
{
    public function modify(WSRequest $request): void
    {
        $tns = 'http://htng.org/1.1/Header/';
        $request->setHeaders([
            new SoapHeader(
                $tns,
                'hb322:HTNGHeader',
                children(
                    namespaced_element($tns, 'hb322:From', children(
                            namespaced_element($tns, 'hb322:systemId', value('APPTEST')),
                            namespaced_element($tns, 'hb322:Credential', children(
                                    namespaced_element($tns, 'hb322:userName', value('someUsername')),
                                    namespaced_element($tns, 'hb322:password', value('somePassword'))
                                )
                            )
                        )
                    ),
                    namespaced_element($tns, 'hb322:timeStamp', value(date('c')))
                )
            ),
        ]);
    }

    public function supports(WSRequest $request): bool
    {
        return $request->webService === 'YourServiceName' && $request->subService === 'YourSubServiceName';
    }

    public static function getPriority(): int
    {
        return 0;
    }
}