PHP code example of paxport / soap-react

1. Go to this page and download the library: Download paxport/soap-react 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/ */

    

paxport / soap-react example snippets


$loop = React\EventLoop\Factory::create();
$browser = new Browser($loop);
$wsdl = 'http://example.com/demo.wsdl';

$browser->get($wsdl)->then(function (ResponseInterface $response) use ($browser) {
    $client = new Client($browser, (string)$response->getBody());
    $api = new Proxy($client);

    $api->getBank(array('blz' => '12070000'))->then(function ($result) {
        var_dump('Result', $result);
    });
});

$loop->run();

$loop = React\EventLoop\Factory::create();
$browser = new Clue\React\Buzz\Browser($loop);

$wsdl = '<?xml …';
$options = array();

$client = new Client($browser, $wsdl, $options);

$connector = new \React\Socket\Connector($loop, array(
    'dns' => '127.0.0.1',
    'tcp' => array(
        'bindto' => '192.168.10.1:0'
    ),
    'tls' => array(
        'verify_peer' => false,
        'verify_peer_name' => false
    )
));

$browser = new Browser($loop, $connector);
$client = new Client($browser, $wsdl);

$browser = new Browser($loop);

$browser->get($url)->then(
    function (ResponseInterface $response) use ($browser) {
        // WSDL file is ready, create client
        $client = new Client($browser, (string)$response->getBody());

        // do something…
    },
    function (Exception $e) {
        // an error occured while trying to download the WSDL
    }
);

try {
    $client = new Client($browser, $wsdl);
} catch (SoapFault $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

$client = new Client($browser, null, array(
    'location' => 'http://example.com',
    'uri' => 'http://ping.example.com',
));

$client = new Client($browser, $wsdl, array(
    'location' => 'http://example.com'
));

$client = new Client($browser, $wsdl, array(
    'soap_version' => SOAP_1_2
));

$client = new Client($browser, $wsdl, array(
    'classmap' => array(
        'getBankResponseType' => BankResponse::class
    )
));

// advanced usage, see Proxy for recommended alternative
$promise = $client->soapCall('ping', array('hello', 42));

$proxy = new Proxy($client);
$promise = $proxy->ping('hello', 42);

assert('http://example.com/soap/service' === $client->getLocation('echo'));

assert('http://example.com/soap/service' === $client->getLocation(0));

$client = $client->withLocation('http://example.com/soap');

assert('http://example.com/soap' === $client->getLocation('echo'));

$proxy = new Proxy($client);

$proxy->myMethod($myArg1, $myArg2)->then(function ($response) {
    // result received
});

$proxy->demo()->then(
    function ($response) {
        // response received for demo function
    },
    function (Exception $e) {
        // an error occured while executing the request
    }
});

$promise = $proxy->demo();

$loop->addTimer(2.0, function () use ($promise) {
    $promise->cancel();
});

$browser = new Browser($loop);
$browser = $browser->withOptions(array(
    'timeout' => 10.0
));

$client = new Client($browser, $wsdl);
$proxy = new Proxy($client);

$proxy->demo()->then(function ($response) {
    // response received within 10 seconds maximum
    var_dump($response);
});