PHPackages                             php-soap/ext-soap-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. php-soap/ext-soap-engine

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

php-soap/ext-soap-engine
========================

An ext-soap engine implementation

1.12.0(1mo ago)443.2M↓17.3%11[1 issues](https://github.com/php-soap/ext-soap-engine/issues)6MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Jul 8Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/php-soap/ext-soap-engine)[ Packagist](https://packagist.org/packages/php-soap/ext-soap-engine)[ Fund](https://opencollective.com/php-soap)[ RSS](/packages/php-soap-ext-soap-engine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (30)Versions (18)Used By (6)

Ext-SOAP powered SOAP engine
============================

[](#ext-soap-powered-soap-engine)

This package is a [SOAP engine](https://github.com/php-soap/engine) that leverages the built-in functions from PHP's `ext-soap` extension.

It basically flips the `SoapClient` inside out: All the built-in functions for encoding, decoding and HTTP transport can be used in a standalone way.

If your package contains a `SoapClient`, you might consider using this package as an alternative:

- It gives you full control over the HTTP layer.
- It validates the `$options` you pass to the `SoapClient` and gives you meaningful errors.
- It transforms the types and methods into real objects so that you can actually use that information.
- It makes it possible to use the encoding / decoding logic without doing any SOAP calls to a server.
- ...

Want to help out? 💚
===================

[](#want-to-help-out-)

- [Become a Sponsor](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#sponsor)
- [Let us do your implementation](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#let-us-do-your-implementation)
- [Contribute](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#contribute)
- [Help maintain these packages](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#maintain)

Want more information about the future of this project? Check out this list of the [next big projects](https://github.com/php-soap/.github/blob/main/PROJECTS.md) we'll be working on.

Installation
============

[](#installation)

```
composer require php-soap/ext-soap-engine
```

Example usage:
--------------

[](#example-usage)

This example contains an advanced setup for creating a flexible ext-soap based engine. It shows you the main components that you can use for configuring PHP's `SoapClient` and to transform it into a SOAP engine:

```
use Soap\Engine\SimpleEngine;
use Soap\ExtSoapEngine\AbusedClient;
use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMapCollection;
use Soap\ExtSoapEngine\Configuration\TypeConverter\TypeConverterCollection;
use Soap\ExtSoapEngine\ExtSoapDriver;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Soap\ExtSoapEngine\Transport\ExtSoapClientTransport;
use Soap\ExtSoapEngine\Transport\TraceableTransport;

$engine = new SimpleEngine(
    ExtSoapDriver::createFromClient(
        $client = AbusedClient::createFromOptions(
            ExtSoapOptions::defaults($wsdl, [
                'soap_version' => SOAP_1_2,
            ])
                ->disableWsdlCache()
                ->withClassMap(new ClassMapCollection())
                ->withTypeMap(new TypeConverterCollection())
        )
    ),
    $transport = new TraceableTransport(
        $client,
        new ExtSoapClientTransport($client)
    )
);
```

Fetching a SOAP Resource:

```
$result = $engine->request('SomeMethod', [(object)['param1' => true]]);

// Collecting last soap call:
var_dump($transport->collectLastRequestInfo());
```

You can still set advanced configuration on the actual SOAP client:

```
$client->__setLocation(...);
$client->__setSoapHeaders(...);
$client->__setCookie(...);
```

Reading / Parsing metadata

```
var_dump(
    $engine->getMetadata()->getMethods(),
    $engine->getMetadata()->getTypes()
);

$methodInfo = $engine->getMetadata()->getMethods()->fetchByName('SomeMethod');
```

Engine
------

[](#engine)

This package provides following engine components:

- **ExtSoapEncoder:** Uses PHP's `SoapClient` in order to encode a mixed request body into a SOAP request.
- **ExtSoapDecoder:** Uses PHP's `SoapClient` in order to decode a SOAP Response into mixed data.
- **ExtSoapMetadata:** Parses the methods and types from PHP's `SoapClient` into something more usable.
- **ExtSoapDriver:** Combines the ext-soap encoder, decoder and metadata tools into a usable `ext-soap` preset.

### Transports

[](#transports)

- **ExtSoapClientTransport:** Uses PHP's `SoapClient` to handle SOAP requests.
- **ExtSoapServerTransport:** Uses PHP's `SoapServer` to handle SOAP requests. It can e.g. be used during Unit tests.
- **TraceableTransport:** Can be used to decorate another transport and keeps track of the last request and response. It should be used as an alternative for fetching it on the SoapClient.

In ext-soap, there are some well known issues regarding the HTTP layer. Therefore we recommend using the [PSR-18 based transport](https://github.com/php-soap/psr18-transport/) instead of the ones above. Besides dealing with some issues, it also provides a set of middleware for dealing with some common issues you might not be able to solve with the regular SoapClient.

Configuration options
---------------------

[](#configuration-options)

### ExtSoapOptions

[](#extsoapoptions)

This package provides a little wrapper around all available `\SoapClient` [options](https://www.php.net/manual/en/soapclient.construct.php). It provides sensible default options. If you want to set specific options, you can do so in a sane way: It will validate the options before they are passed to the `\SoapClient`. This way, you'll spend less time browsing the official PHP documentation.

```
