PHP code example of nhkey / yii2-soap

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

    

nhkey / yii2-soap example snippets


'components' => [
    'soapClient' => [
        'class' => \nhkey\soap\SoapClientWrapper::className(),
        'url' => '<SOAP_WSDL_URL>',
        // SoapClient options
        'options' => [
            'cache_wsdl' => WSDL_CACHE_NONE,
            'debug' => true,
        ],
        // SopaClient headers, object or closure
        'headers' => function() {
            $headers = new stdClass();
            $headers->authDetails = new stdClass(); // This is node in SOAP Header where the login and password.
            $headers->authDetails->login = 'LOGIN';
            $headers->authDetails->password = 'PASSWORD';
            return $headers;
        }
    ],
    ...
]

try {
    $soap = Yii::$app->soapClient;
    $result = $soap->makeSmb(['arg1' => 'foo', 'arg2' => 'bar']);
} catch (SoapClientWrapperException $e) {
    return ['request' => $soap->getLastRequest(), 'response' => $soap->getLastResponse()];
}


php composer.phar