cansozeri / php-soap-client
A PHP library for interpreting and binding SOAP messages to PSR-7 HTTP messages
Requires
- php: ^7.2
- ext-dom: *
- ext-json: *
- ext-soap: *
- ext-xml: *
- psr/log: ^1.1
- symfony/event-dispatcher: ~5.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.3@dev
- php-http/client-common: ^2
- php-http/client-implementation: ^1
- php-http/discovery: ^1.7
- php-http/guzzle6-adapter: ^2.0
- php-http/httplug: ^2
- php-http/message: ^1.8
- php-http/message-factory: ^1.0
- php-http/mock-client: ^1.4
- phpunit/phpunit: ^8.5
- psr/http-message: ^1.0
This package is auto-updated.
Last update: 2024-11-17 16:44:24 UTC
README
This package aims to help you with interpreting and binding SOAP 1.1 and SOAP 1.2 messages to PSR-7 HTTP messages.
Installation
$ composer require cansozeri/php-soap-client
Usage
SoapDriver
❗️ Make sure ext-soap is loaded.
This soap driver wraps PHPs ext-soap \SoapClient
implementation.
- It abuses the
__doRequest()
method to make it possible to encode the request and decode the response. - Metadata is being parsed based on the
__getTypes()
and__getFunctions()
method.
Example usage
- You can use SoapEngine Trait to create a "Soap Service" Instance.
<?php use Canszr\SoapClient\SoapEngine; use Canszr\SoapClient\SoapOptions; use SoapEngine; $options = SoapOptions::defaults($wsdl, [ 'soap_version' => SOAP_1_2, ])->disableWsdlCache(); $service = $this->fromOptions($options);
SoapOptions
This package provides a little wrapper around all available \SoapClient
options.
We provide some default options and the additional options can be configured.
It will validate the options before they are passed to the \SoapClient
.
This way, you'll spend less time browsing the official PHP documentation.
Example usage
<?php use Canszr\SoapClient\SoapOptions; $options = SoapOptions::defaults($wsdl, ['soap_version' => SOAP_1_2]) ->disableWsdlCache(); $typemap = $options->getTypeMap(); $typemap->add(new MyTypeConverter());
Handlers
HttPlugHandle
Features: LastRequestInfoCollector, MiddlewareSupporting
HTTPlug is a HTTP client abstraction that can be used with multiple client packages. With this handler it is easy to get in control about the HTTP layer of the SOAP client. You can specify one or multiple middlewares that are being applied on your http client. This makes it possible to manipulate the request and response objects so that you can get full control.
This handler knows how to deal with HTTP middlewares if they are supported by your HTTP client.
Dependencies
Load HTTP plug core packages:
composer require psr/http-message:^1.0 php-http/httplug:^2.1 php-http/message-factory:^1.0 php-http/discovery:^1.7 php-http/message:^1.8 php-http/client-common:^2.1
Select HTTP Client
Select one of the many clients you want to use to perform the HTTP requests: http://docs.php-http.org/en/latest/clients.html#clients-adapters
composer require php-http/client-implementation:^1.0
Example usage
<?php use Canszr\SoapClient\Handler\HttPlugHandle; use Canszr\SoapClient\SoapEngine; use Canszr\SoapClient\SoapOptions; use Canszr\SoapClient\Middleware\BasicAuthMiddleware; use Http\Adapter\Guzzle6\Client; use SoapEngine; $options = SoapOptions::defaults($wsdl, [ 'soap_version' => SOAP_1_2, ])->disableWsdlCache(); $handler = HttPlugHandle::createForClient( Client::createWithConfig(['headers' => ['User-Agent' => 'testing/1.0']]) ); $handler->addMiddleware(new BasicAuthMiddleware('user', 'password')); $service = $this->fromOptionsWithHandler($options, $handler);
SoapClientHandle
Features: LastRequestInfoCollector
❗️ Make sure ext-soap is loaded.
The SoapClientHandle is used by default and works with the built-in __doRequest()
method.
This Handle is not configurable and can be used for soap implementations which do not use extensions.
It is activated by default to get you going as quick as possible.
Example usage
<?php use Canszr\SoapClient\SoapEngine; use Canszr\SoapClient\SoapOptions; use SoapEngine; $service = $this->fromOptions(SoapOptions::defaults($wsdl, []));