PHP code example of php-soap / wsdl-reader

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


use Soap\Engine\Metadata\Model\Method;
use Soap\Engine\Metadata\Model\Type;
use Soap\Wsdl\Loader\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\WsdlReader\Formatter\ShortMethodFormatter;
use Soap\WsdlReader\Formatter\ShortTypeFormatter;
use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
use Soap\WsdlReader\Wsdl1Reader;

// Reading WSDL
$loader = new FlatteningLoader(new StreamWrapperLoader());
$wsdl = (new Wsdl1Reader($loader))($wsdlLocation);

// Parsing metadata
$metadataProvider = new Wsdl1MetadataProvider($wsdl);
$metadata = $metadataProvider->getMetadata();

// Processing collected info:
var_dump($metadata->getMethods(), $metadata->getTypes());

use Soap\WsdlReader\Locator\ServiceSelectionCriteria;
use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
use Soap\WsdlReader\Model\Definitions\SoapVersion;
use Soap\WsdlReader\Wsdl1Reader;

$wsdl = (new Wsdl1Reader($loader))($wsdlLocation);

$criteria = ServiceSelectionCriteria::defaults()
    ->withPreferredSoapVersion(SoapVersion::SOAP_12);

$metadataProvider = new Wsdl1MetadataProvider($wsdl, $criteria);



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

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