2017 © Pedro Peláez
 

library soap-http-binding

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

image

meng-tian/soap-http-binding

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  • Wednesday, May 10, 2017
  • by meng-tian
  • Repository
  • 2 Watchers
  • 8 Stars
  • 156,831 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 19 % Grown

The README.md

SOAP HTTP Binding codecov.io workflow

This library binds SOAP 1.1 and SOAP 1.2 messages to PSR-7 HTTP messages., (*1)

Requirement

PHP 7.1, (*2)

Install

composer require meng-tian/soap-http-binding

Usage

HttpBinding::request embeds SOAP reqeust messages into PSR-7 HTTP requests., (*3)

use Meng\Soap\HttpBinding\HttpBinding;
use Meng\Soap\HttpBinding\RequestBuilder;
use Meng\Soap\Interpreter;
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\StreamFactory;

$interpreter = new Interpreter('http://www.webservicex.net/airport.asmx?WSDL');
$streamFactory = new StreamFactory();
$requestFactory = new RequestFactory();
$builder = new RequestBuilder($streamFactory, $requestFactory);
$httpBinding = new HttpBinding($interpreter, $builder, $streamFactory);

$request = $httpBinding->request('GetAirportInformationByCountry', [['country' => 'United Kingdom']]);
echo \Laminas\Diactoros\Request\Serializer::toString($request);

Output:, (*4)

POST /airport.asmx HTTP/1.1
Content-Length: 322
SOAPAction: http://www.webserviceX.NET/GetAirportInformationByCountry
Content-Type: text/xml; charset="utf-8"
Host: www.webservicex.net


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.webserviceX.NET"><SOAP-ENV:Body><ns1:GetAirportInformationByCountry><ns1:country>United Kingdom</ns1:country></ns1:GetAirportInformationByCountry></SOAP-ENV:Body></SOAP-ENV:Envelope>

HttpBinding::response retrieves SOAP response messages from PSR-7 HTTP responses:, (*5)

use Meng\Soap\HttpBinding\HttpBinding;
use Meng\Soap\HttpBinding\RequestBuilder;
use Meng\Soap\Interpreter;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\Stream;
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\StreamFactory;

$response = <<<EOD
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetAirportInformationByCountryResponse xmlns="http://www.webserviceX.NET">
      <GetAirportInformationByCountryResult>some result</GetAirportInformationByCountryResult>
    </GetAirportInformationByCountryResponse>
  </soap:Body>
</soap:Envelope>
EOD;

$stream = new Stream('php://memory', 'r+');
$stream->write($response);
$stream->rewind();
$response = new Response($stream, 200, ['Content-Type' => 'text/xml; charset=utf-8']);

$interpreter = new Interpreter('http://www.webservicex.net/airport.asmx?WSDL');
$streamFactory = new StreamFactory();
$requestFactory = new RequestFactory();
$builder = new RequestBuilder($streamFactory, $requestFactory);
$httpBinding = new HttpBinding($interpreter, $builder, $streamFactory);
$response = $httpBinding->response($response, 'GetAirportInformationByCountry');

print_r($response);

Output:, (*6)

stdClass Object
(
    [GetAirportInformationByCountryResult] => some result
)

This library also support SOAP 1.2 HTTP GET binding through RequestBuilder class :, (*7)

use Meng\Soap\HttpBinding\RequestBuilder;
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\StreamFactory;

$streamFactory = new StreamFactory();
$requestFactory = new RequestFactory();
$builder = new RequestBuilder($streamFactory, $requestFactory);
$request = $builder->isSOAP12()
    ->setEndpoint('http://www.endpoint.com')
    ->setHttpMethod('GET')
    ->getSoapHttpRequest();
echo \Laminas\Diactoros\Request\Serializer::toString($request);

Output:, (*8)

GET / HTTP/1.1
Accept: application/soap+xml
Host: www.endpoint.com

License

This library is released under MIT license., (*9)

The Versions

10/05 2017

dev-master

9999999-dev

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

21/05 2016

0.2.3

0.2.3.0

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

22/04 2016

0.2.2

0.2.2.0

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

21/04 2016

0.2.1

0.2.1.0

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

19/04 2016

0.2.0

0.2.0.0

A PHP library for binding SOAP messages to PSR-7 HTTP messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

18/04 2016

0.1.2

0.1.2.0

A PHP library for binding SOAP messages to PSR-7 HTTP requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

29/02 2016

0.1.1

0.1.1.0

A PHP library for binding SOAP messages to PSR-7 HTTP requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian

psr-7 http soap

29/02 2016

0.1.0

0.1.0.0

A PHP library for binding SOAP messages to HTTP.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Meng Tian