PHP code example of vaclavvanik / soap-interpreter

1. Go to this page and download the library: Download vaclavvanik/soap-interpreter 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-interpreter example snippets




declare(strict_types=1);

use VaclavVanik\Soap\Interpreter\PhpInterpreter;

$interpreter = PhpInterpreter::fromWsdl('http://www.dneonline.com/calculator.asmx?wsdl');



declare(strict_types=1);

use VaclavVanik\Soap\Interpreter\PhpInterpreter;

$interpreter = PhpInterpreter::fromNonWsdl('http://tempuri.org/', 'http://www.dneonline.com/calculator.asmx');



declare(strict_types=1);

use VaclavVanik\Soap\Interpreter\PhpInterpreter;

$request = (PhpInterpreter::fromWsdl('http://www.dneonline.com/calculator.asmx?wsdl'))->request('Add', ['Add' => ['intA' => 1, 'intB' => 3]]);
print_r($request->getBody());



declare(strict_types=1);

use VaclavVanik\Soap\Interpreter\PhpInterpreter;

$response = <<<XML
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
        <ns1:AddResponse xmlns:ns1="http://tempuri.org/">
          <ns1:AddResult>4</ns1:AddResult>
        </ns1:AddResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML;

$response = (PhpInterpreter::fromWsdl('http://www.dneonline.com/calculator.asmx?wsdl'))->response('Add', $response);
print_r($response->getResult());

stdClass Object
(
    [AddResult] => 4
)