PHPackages                             php-soap/xml - 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/xml

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

php-soap/xml
============

XML wrappers for SOAP

1.10.0(1mo ago)103.5M—9.2%1[1 issues](https://github.com/php-soap/xml/issues)10MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Jul 8Pushed 7mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (15)Used By (10)

SOAP XML
========

[](#soap-xml)

This package provides some tools on top of [veewee/xml](https://github.com/veewee/xml)'s DOM component in order to make it easier to deal with SOAP XML structures.

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/xml
```

Builder
-------

[](#builder)

### SoapHeaders

[](#soapheaders)

Makes it possible to build the content of a `soap:Header` element.

```
use Soap\Xml\Builder\SoapHeaders;
use Soap\Xml\Builder\SoapHeader;
use Soap\Xml\Builder\Header\Actor;
use Soap\Xml\Builder\Header\MustUnderstand;
use Soap\Xml\Manipulator\PrependSoapHeaders;
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Builder\element;
use function VeeWee\Xml\Dom\Builder\value;

$doc = Document::fromXmlString($xml);
$builder = new SoapHeaders(
    new SoapHeader(
        $targetNamespace,
        'Auth',
        children(
            namespaced_element($targetNamespace, 'user', value('josbos')),
            namespaced_element($targetNamespace, 'password', value('topsecret'))
        ),
        // Optionally, you can provide additional configurators for setting
        // SOAP-ENV specific attributes:
        Actor::next(),
        new MustUnderstand()
    ),
    $header2,
    $header3
);

$headers = $doc->build($builder);

// You can prepend the soap:Header as first element of the soap:envelope
// Like this
$doc->manipulate(new PrependSoapHeaders(...$headers));
```

*Note*: The SoapHeader(s) can be configured by using any [DOM builder configurator](https://github.com/veewee/xml/blob/master/docs/dom.md#builders).

Locator
-------

[](#locator)

### BodyNamespaceLocator

[](#bodynamespacelocator)

Locates the namespace of the first element inside the soap:Body.

```
use Soap\Xml\Locator\BodyNamespaceLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyNamespace = $doc->locate(new BodyNamespaceLocator());
```

### SoapBodyLocator

[](#soapbodylocator)

Locates the `soap:Body` element inside a `soap:Envelope`

```
use Soap\Xml\Locator\SoapBodyLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapBodyLocator());
```

### SoapEnvelopeLocator

[](#soapenvelopelocator)

Locates the `soap:Envelope` inside XML.

```
use Soap\Xml\Locator\SoapEnvelopeLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapEnvelopeLocator());
```

### SoapHeaderLocator

[](#soapheaderlocator)

Locates the `soap:Header` element inside a `soap:Envelope`

```
use Soap\Xml\Locator\SoapHeaderLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapHeaderLocator());
```

Manipulator
-----------

[](#manipulator)

### PrependSoapHeaders

[](#prependsoapheaders)

See SoapHeaders builder:

```
$doc = Document::fromXmlString($xml);
$doc->manipulate(new PrependSoapHeaders($soapHeader));
```

XPath
-----

[](#xpath)

### EnvelopePreset

[](#envelopepreset)

This preset allows you to use following xpath prefixes:

- `application`: The namespace of the SOAP implementation.
- `soap`: The soap prefix allows you to fetch common elements like Body, header, Envelope, ...

```
use Soap\Xml\Xpath\EnvelopePreset;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$xpath = $doc->xpath(new EnvelopePreset($doc));

$xpath->querySingle('/soap:Envelope');
$xpath->querySingle('//soap:Body');
$xpath->querySingle('//soap:Header');
$xpath->querySingle('//soap:Body//application:Foo');
```

### WsdlPreset

[](#wsdlpreset)

This preset allows you to use following xpath prefixes:

- `wsdl`: The wsdl prefix allows you to fetch common elements like definitions, types, services, operations, ...

```
use Soap\Xml\Xpath\WsdlPreset;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$xpath = $doc->xpath(new WsdlPreset($doc));

$xpath->querySingle('/wsdl:definitions');
$xpath->querySingle('//wsdl:types');
$xpath->querySingle('//wsdl:services');
```

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance74

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 94.4% 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

Every ~132 days

Recently: every ~185 days

Total

14

Last Release

53d ago

Major Versions

v0.1.0 → v1.0.02021-09-24

PHP version history (6 changes)v0.1.0PHP ^8.0

v1.4.0PHP ~8.1.0 || ~8.2.0

1.5.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.8.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

1.9.0PHP ~8.3.0 || ~8.4.0 || ~8.5.0

1.10.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

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

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (34 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-soap-xml/health.svg)

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

###  Alternatives

[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)[php-soap/wsdl-reader

A WSDL reader in PHP

212.3M9](/packages/php-soap-wsdl-reader)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)

PHPackages © 2026

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