PHPackages                             alpari/soap-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. alpari/soap-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

alpari/soap-client
==================

Soap client with additional features

v1.0.0(7y ago)2101MITPHPPHP ~7.1

Since Dec 13Pushed 7y ago3 watchersCompare

[ Source](https://github.com/alpari-tech/soap-client)[ Packagist](https://packagist.org/packages/alpari/soap-client)[ RSS](/packages/alpari-soap-client/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (7)Versions (1)Used By (0)

Soap client
===========

[](#soap-client)

Extended PHP soap client with additional features.

Features
--------

[](#features)

1. Timeout support for requests
2. Asynchronous SOAP requests
3. Custom HTTP-request headers
4. Logging support with PSR-3-compatible logger
5. Special test client for writing tests on your server

Prerequisites
-------------

[](#prerequisites)

The `soap`, `dom`, `curl`, `libxml` extensions must be pre-installed on the server in order to use this library.

Installing
----------

[](#installing)

The recommended way is using a [composer](https://getcomposer.org/download/)

```
$ composer require alpari/soap-client:~1.0 --prefer-dist|--prefer-source

```

Usage
-----

[](#usage)

### Simple SOAP request

[](#simple-soap-request)

```
use Alpari\Components\SoapClient\Client\SoapClient;

$client = new SoapClient('http://example.com/service?wsdl');

$result = $client->targetServiceMethod(1, 2);
```

### Async SOAP requests

[](#async-soap-requests)

This feature execute multiple SOAP requests in parallel.

```
use Alpari\Components\SoapClient\Client\SoapClient;

$client = new SoapClient('http://example.com/service?wsdl');
$responses = $client->async(function (SoapClient $client) {
    $client->methodA(25);
    $client->methodB(64);
});
```

The *responses* variable will contain the result of all calls made inside `async` function in order they were called there. In example above the *responses\[0\]* is the return value of remote method `methodA`, *response\[1\]* is the return value of `methodB`. If there was an exception during some method call, the corresponding array item will contain an exception object of `SoapFault` class.

### Requests with timeout

[](#requests-with-timeout)

To set timeout for request use `setTimeout` value with a single parameter - time to wait request completion in milliseconds. If `setTimeout` method is not called explicitly, the value of php-ini setting `default_socket_timeout` will be used.

```
$client = new SoapClient('http://example.com/service?wsdl');

$client->setTimeout(60000); // in milli-seconds

$result = $client->targetServiceMethod(1, 2);
```

### Passing custom HTTP headers

[](#passing-custom-http-headers)

```
$client = new SoapClient('http://example.com/service?wsdl');

$client->setHeader('X-Header-Name', 'A value');

$result = $client->targetServiceMethod(1, 2);
```

### Logging requests

[](#logging-requests)

The `SoapClient` implements `Psr\Log\LoggerAwareInterface`.

```
use Psr\Log\NullLogger;

$client = new SoapClient('http://example.com/service?wsdl');

$client->setLogger(new NullLogger());

$result = $client->targetServiceMethod(1, 2);
```

### SOAP client constructor options

[](#soap-client-constructor-options)

This implementation of SOAP client supports additional array of options:

- `local_cert` - client certificate file name to use for SSL connection.
- `local_key` - private for client certificate, if it is stored as a separate file.
- `passphrase` - password for certificate private key.
- `ca_bundle` - file name with trusted CAs for verifying server certificate. If not provided, the system one is used.
- `curl` - array with additional curl options. See all possible options [here](http://php.net/manual/en/function.curl-setopt.php).
- `cache_prefix` - file name prefix for generated wsdl cache file names

### Testing own SOAP servers

[](#testing-own-soap-servers)

To test your own SOAP server you need to install additional packages if you steel don't have them in a project:

```
composer require --dev symfony/http-kernel symfony/browser-kit
```

If the project is based on [Symfony framework](https://symfony.com), just use `Alpari\Components\SoapClient\Test\TestSoapClient` in the test-case

```
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Alpari\Components\SoapClient\Test\TestSoapClient;

class SoapServiceTest extends WebTestCase
{
    public function testSoapServiceMethod()
    {
        $httpClient = static::createClient();
        $soapClient = new TestSoapClient($soapClient, 'wsdl url');

        $result = $soapClient->SoapServiceMethod('Method args');

        self::assertEquals(200, $httpClient->getResponse()->getStatusCode());
        self::assertEquals('something', $result);
    }
}
```

If the project is based on some other framework you will need an implementation of `Symfony\Component\HttpKernel\HttpKernelInterface`in your test which will redirect all calls to application's entry point and return symfony `Response` object:

```
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Alpari\Components\SoapClient\Test\TestSoapClient;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Response;

class SoapServiceTest extends TestCase
{
    public function testSoapServiceMethod()
    {
        $httpClient = new Client(new class implements HttpKernelInterface {
            public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
            {
                return new Response(
                  // rendered content from application front controller
                );
            }
        });
        $soapClient = new TestSoapClient($soapClient, 'wsdl url');

        $result = $soapClient->SoapServiceMethod('Method args');

        self::assertEquals(200, $httpClient->getResponse()->getStatusCode());
        self::assertEquals('something', $result);
    }
}
```

Running the tests
-----------------

[](#running-the-tests)

Tests are written with phpunit. To run the tests use the following command:

```
vendor/bin/phpunit -c phpunit.xml.dist
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2708d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b13cda5a6abe4145f839778ed29e07e019a06a3120156aa70e5d9733d8116cb3?d=identicon)[Alpari](/maintainers/Alpari)

---

Top Contributors

[![edefimov](https://avatars.githubusercontent.com/u/12027442?v=4)](https://github.com/edefimov "edefimov (5 commits)")

---

Tags

phpsoapsoap-client

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alpari-soap-client/health.svg)

```
[![Health](https://phpackages.com/badges/alpari-soap-client/health.svg)](https://phpackages.com/packages/alpari-soap-client)
```

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k822.4M6.8k](/packages/symfony-http-kernel)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
