PHP code example of vaclavvanik / soap-binding

1. Go to this page and download the library: Download vaclavvanik/soap-binding library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vaclavvanik / soap-binding example snippets




declare(strict_types=1);

use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\Request\Serializer;
use Laminas\Diactoros\StreamFactory;
use VaclavVanik\Soap\Binding\InterpreterBinding;
use VaclavVanik\Soap\Binding\PsrRequestFactory;
use VaclavVanik\Soap\Interpreter\PhpInterpreter;

$factory = new PsrRequestFactory(new RequestFactory(), new StreamFactory());
$interpreter = PhpInterpreter::fromWsdl('http://www.dneonline.com/calculator.asmx?wsdl');

$httpBinding = new InterpreterBinding($interpreter, $factory);
$psrRequest = $httpBinding->request('Add', ['Add' => ['intA' => 1, 'intB' => 3]]);

echo Serializer::toString($psrRequest);


//$psrResponse = $client->sendRequest($psrRequest);

$result = $httpBinding->response('Add', $psrResponse);

print_r($result->getResult());

stdClass Object
(
    [AddResult] => 4
)