@@ -67,8 +67,11 @@ Once [installed](#install), you can use the following code to query an example
6767web service via SOAP:
6868
6969``` php
70- $loop = React\EventLoop\Factory::create();
71- $browser = new React\Http\Browser($loop);
70+ <?php
71+
72+ require __DIR__ . '/vendor/autoload.php';
73+
74+ $browser = new React\Http\Browser();
7275$wsdl = 'http://example.com/demo.wsdl';
7376
7477$browser->get($wsdl)->then(function (Psr\Http\Message\ResponseInterface $response) use ($browser) {
@@ -79,8 +82,6 @@ $browser->get($wsdl)->then(function (Psr\Http\Message\ResponseInterface $respons
7982 var_dump('Result', $result);
8083 });
8184});
82-
83- $loop->run();
8485```
8586
8687See also the [ examples] ( examples ) .
@@ -90,30 +91,26 @@ See also the [examples](examples).
9091### Client
9192
9293The ` Client ` class is responsible for communication with the remote SOAP
93- WebService server.
94-
95- It requires a [ ` Browser ` ] ( https://github.com/reactphp/http#browser ) object
96- bound to the main [ ` EventLoop ` ] ( https://github.com/reactphp/event-loop#usage )
97- in order to handle async requests, the WSDL file contents and an optional
94+ WebService server. It requires the WSDL file contents and an optional
9895array of SOAP options:
9996
10097``` php
101- $loop = React\EventLoop\Factory::create();
102- $browser = new React\Http\Browser($loop);
103-
10498$wsdl = '<?xml … ' ;
10599$options = array();
106100
107- $client = new Clue\React\Soap\Client($browser , $wsdl, $options);
101+ $client = new Clue\React\Soap\Client(null , $wsdl, $options);
108102```
109103
104+ This class takes an optional `Browser|null $browser` parameter that can be used to
105+ pass the browser instance to use for this object.
110106If you need custom connector settings (DNS resolution, TLS parameters, timeouts,
111107proxy servers etc.), you can explicitly pass a custom instance of the
112108[`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface)
113- to the [`Browser`](https://github.com/reactphp/http#browser) instance:
109+ to the [`Browser`](https://github.com/reactphp/http#browser) instance
110+ and pass it as an additional argument to the `Client` like this:
114111
115112```php
116- $connector = new React\Socket\Connector($loop, array(
113+ $connector = new React\Socket\Connector(array(
117114 ' dns ' => ' 127.0.0.1 ' ,
118115 ' tcp ' => array(
119116 ' bindto ' => ' 192.168.10.1:0 '
@@ -124,7 +121,7 @@ $connector = new React\Socket\Connector($loop, array(
124121 )
125122));
126123
127- $browser = new React\Http\Browser($loop, $ connector);
124+ $browser = new React\Http\Browser($connector);
128125$client = new Clue\React\Soap\Client($browser, $wsdl);
129126```
130127
@@ -134,7 +131,7 @@ you to use local WSDL files, WSDL files from a cache or the most common form,
134131downloading the WSDL file contents from an URL through the `Browser`:
135132
136133```php
137- $browser = new React\Http\Browser($loop );
134+ $browser = new React\Http\Browser();
138135
139136$browser- >get($url)- >then(
140137 function (Psr\Http\Message\ResponseInterface $response) use ($browser) {
@@ -155,7 +152,7 @@ parsed, this will throw a `SoapFault`:
155152
156153```php
157154try {
158- $client = new Clue\React\Soap\Client($browser , $wsdl);
155+ $client = new Clue\React\Soap\Client(null , $wsdl);
159156} catch (SoapFault $e) {
160157 echo ' Error: ' . $e- >getMessage() . PHP_EOL;
161158}
@@ -179,7 +176,7 @@ the URL of the SOAP server to send the request to, and `uri` is the target
179176namespace of the SOAP service:
180177
181178```php
182- $client = new Clue\React\Soap\Client($browser , null, array(
179+ $client = new Clue\React\Soap\Client(null , null, array(
183180 ' location' => ' http://example.com' ,
184181 ' uri' => ' http://ping.example.com' ,
185182));
@@ -189,7 +186,7 @@ Similarly, if working in WSDL mode, the `location` option can be used to
189186explicitly overwrite the URL of the SOAP server to send the request to:
190187
191188```php
192- $client = new Clue\React\Soap\Client($browser , $wsdl, array(
189+ $client = new Clue\React\Soap\Client(null , $wsdl, array(
193190 ' location' => ' http://example.com'
194191));
195192```
@@ -198,7 +195,7 @@ You can use the `soap_version` option to change from the default SOAP 1.1 to
198195use SOAP 1.2 instead:
199196
200197```php
201- $client = new Clue\React\Soap\Client($browser , $wsdl, array(
198+ $client = new Clue\React\Soap\Client(null , $wsdl, array(
202199 ' soap_version' => SOAP_1_2
203200));
204201```
@@ -207,7 +204,7 @@ You can use the `classmap` option to map certain WSDL types to PHP classes
207204like this:
208205
209206```php
210- $client = new Clue\React\Soap\Client($browser , $wsdl, array(
207+ $client = new Clue\React\Soap\Client(null , $wsdl, array(
211208 ' classmap' => array(
212209 ' getBankResponseType' => BankResponse::class
213210 )
@@ -366,7 +363,7 @@ clean up any underlying resources.
366363```php
367364$promise = $proxy- >demo();
368365
369- $loop- > addTimer(2.0, function () use ($promise) {
366+ Loop:: addTimer(2.0, function () use ($promise) {
370367 $promise- >cancel();
371368});
372369```
@@ -389,7 +386,7 @@ pass the timeout to the [underlying `Browser`](https://github.com/reactphp/http#
389386like this:
390387
391388```php
392- $browser = new React\Http\Browser($loop );
389+ $browser = new React\Http\Browser();
393390$browser = $browser->withTimeout(10.0);
394391
395392$client = new Clue\React\Soap\Client($browser, $wsdl);
0 commit comments