PHP code example of meng-tian / php-soap-interpreter

1. Go to this page and download the library: Download meng-tian/php-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/ */

    

meng-tian / php-soap-interpreter example snippets


$interpreter = new Interpreter('http://www.webservicex.net/length.asmx?WSDL');
$request = $interpreter->request(
    'ChangeLengthUnit',
    [['LengthValue'=>'1', 'fromLengthUnit'=>'Inches', 'toLengthUnit'=>'Meters']]
);

print_r($request->getSoapMessage());

$interpreter = new Interpreter('http://www.webservicex.net/length.asmx?WSDL');
$response = <<<EOD
<?xml version="1.0" encoding="utf-8"

/*
Output:
stdClass Object
(
    [ChangeLengthUnitResult] => 0.0254
)
*/

// In non-WSDL mode, location and uri must be provided as they are ervicex.net/length.asmx', 'uri'=>'http://www.webserviceX.NET/']);
$request = $interpreter->request(
    'ChangeLengthUnit',
    [
        new SoapParam('1', 'ns1:LengthValue'),
        new SoapParam('Inches', 'ns1:fromLengthUnit'),
        new SoapParam('Meters', 'ns1:toLengthUnit')
    ],
    ['soapaction'=>'http://www.webserviceX.NET/ChangeLengthUnit']
);

print_r($request->getSoapMessage());

$interpreter = new Interpreter('http://www.webservicex.net/CurrencyConvertor.asmx?WSDL');
$request = $interpreter->request('ConversionRate', [['FromCurrency' => 'AFA', 'ToCurrency' => 'ALL']], null, [new SoapHeader('www.namespace.com', 'test_header', 'header_data')]);
print_r($request->getSoapMessage());

composer