PHP code example of php-soap / wsdl

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

    

php-soap / wsdl example snippets


use Http\Client\Common\PluginClient;
use Soap\Psr18Transport\Wsdl\Psr18Loader;

$loader = Psr18Loader::createForClient(
    $wsdlClient = new PluginClient(
        $psr18Client,
        ...$middleware
    )
);

$contents = $loader('http://some.wsdl');

use Soap\Wsdl\Loader\StreamWrapperLoader;

$loader = new StreamWrapperLoader(
    stream_context_create([
        'http' => [
            'method' => 'GET',
            'header'=>"User-Agent: my loader\r\n",
        ],        
    ])
);
$contents = $loader($wsdl);

use Soap\Wsdl\Loader\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;

$loader = new FlatteningLoader(new StreamWrapperLoader());

$contents = $loader($wsdl);

use Soap\Wsdl\Loader\CallbackLoader;

$loader = new CallbackLoader(static function (string $location) use ($loader, $style): string {
    $style->write('> Loading '.$location . '...');

    $result =  $loader($location);
    $style->writeln(' DONE!');

    return $result;
})

$contents = $loader($wsdl);



use Soap\Wsdl\Loader\StreamWrapperLoader;

return new StreamWrapperLoader(
    stream_context_create([
        'http' => [
            'method' => 'GET',
            'header'=> sprintf('Authorization: Basic %s', base64_encode('username:password')),
        ],        
    ])
);

use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\Wsdl\Xml\Validator;
use VeeWee\Xml\Dom\Document;

$wsdl = Document::fromXmlString((new StreamWrapperLoader())($file));

echo "Validating Schemas".PHP_EOL;
$issues = $wsdl->validate(new Validator\SchemaSyntaxValidator());
echo ($issues->count() ? $issues->toString() : '🟢 ALL GOOD').PHP_EOL;
bash
composer