PHP code example of clue / soap-react

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

    

clue / soap-react example snippets




ser = new React\Http\Browser();
$wsdl = 'http://example.com/demo.wsdl';

$browser->get($wsdl)->then(function (Psr\Http\Message\ResponseInterface $response) use ($browser) {
    $client = new Clue\React\Soap\Client($browser, (string)$response->getBody());
    $api = new Clue\React\Soap\Proxy($client);

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

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

$client = new Clue\React\Soap\Client(null, $wsdl, $options);

$connector = new React\Socket\Connector(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 React\Http\Browser($connector);
$client = new Clue\React\Soap\Client($browser, $wsdl);

$browser = new React\Http\Browser();

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

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

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

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

$client = new Clue\React\Soap\Client(null, $wsdl, array(
    'location' => 'http://example.com'
));

$client = new Clue\React\Soap\Client(null, $wsdl, array(
    'soap_version' => SOAP_1_2
));

$client = new Clue\React\Soap\Client(null, $wsdl, array(
    'classmap' => array(
        'getBankResponseType' => BankResponse::class
    )
));

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

$proxy = new Clue\React\Soap\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'));

$client = $client->withHeaders([new SoapHeader(...)]);

$proxy = new Clue\React\Soap\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 React\Http\Browser();
$browser = $browser->withTimeout(10.0);

$client = new Clue\React\Soap\Client($browser, $wsdl);
$proxy = new Clue\React\Soap\Proxy($client);

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