| 1 |
<?php |
| 2 |
|
| 3 |
class MbeSoapClient extends SoapClient { |
| 4 |
|
| 5 |
public $isOnlinembe = false; |
| 6 |
private $helper; |
| 7 |
|
| 8 |
public function __construct( $wsdl, array $options = null, $username = null, $password = null, $wsdlcache = true) |
| 9 |
{ |
| 10 |
$this->helper = new Mbe_Shipping_Helper_Data(); |
| 11 |
if ($this->helper->isOnlineMBE()) { |
| 12 |
$options['cache_wsdl'] = WSDL_CACHE_NONE; |
| 13 |
parent::__construct( $wsdl, $options ); |
| 14 |
} |
| 15 |
else |
| 16 |
{ |
| 17 |
$opts = array( |
| 18 |
'ssl' => array( |
| 19 |
'verify_peer' => false, |
| 20 |
'verify_peer_name' => false, |
| 21 |
'allow_self_signed' => true |
| 22 |
), |
| 23 |
'http' => array( |
| 24 |
'protocol_version' => 1.0 |
| 25 |
) |
| 26 |
); |
| 27 |
$context = stream_context_create($opts); |
| 28 |
|
| 29 |
$soapClientOptions = array( |
| 30 |
'trace' => 1, |
| 31 |
'stream_context' => $context, |
| 32 |
'login' => $username, |
| 33 |
'password' => $password, |
| 34 |
'location' => preg_replace('/(\/e-link\.wsdl)$/i', '', $wsdl), |
| 35 |
// Removed as requested in the "Performance optimization through smart caching" document, so cache is always used |
| 36 |
// 'cache_wsdl' => $wsdlcache?WSDL_CACHE_MEMORY: WSDL_CACHE_NONE, |
| 37 |
); |
| 38 |
|
| 39 |
parent::__construct( $wsdl, $soapClientOptions ); |
| 40 |
} |
| 41 |
} |
| 42 |
#[\ReturnTypeWillChange] |
| 43 |
public function __soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) { |
| 44 |
if (!$this->helper->isOnlineMBE()) { |
| 45 |
$arguments[0]->RequestContainer->Credentials->Username = ''; |
| 46 |
$arguments[0]->RequestContainer->Credentials->Passphrase = ''; |
| 47 |
} |
| 48 |
return parent::__soapCall( $function_name, $arguments, $options, $input_headers, $output_headers ); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
} |