PHP code example of drewlabs / soap-client

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

    

drewlabs / soap-client example snippets


use Drewlabs\Soap\Http\SoapHttpClientFactory;

// ...

// Defines soap options
$options = [
  // ...
];
// Create request client
$factory = new SoapHttpClientFactory();
$client = $factory->create(
    new Client(),
    new StreamFactory, // Provide your own PSR7 StreamFactory or use nyholm/psr7 package
    new Psr7RequestFactory, // Provide your own PSR7 RequestFactory or use nyholm/psr7 package
    '<WSDL_URL>',
    $options,
    null // \Drewlabs\Soap\Contracts\RequestInterface::class (Class name of the class to use in parsing request parameters). 
    // You can use it to transform request body
);

// Making synchronous call
$result = $client->send($method, [
  //... SOAP parameters
]);

// Making async call
$promise = $client->sendAsync($method, [
  //... SOAP parameters
]);
$result = $promise->wait();