From 51d1abab488a2237abf46f811dc6b63d8fee0b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Bechyn=C4=9B?= Date: Thu, 24 Nov 2016 12:47:01 +0100 Subject: [PATCH] Connection: Keep-alive is now configurable - BUT NOW WORKING PHP is unable to change Connection type, this configuration is quite missleading for SoapServer, but still working for SoapClient --- .../SoapCommon/SoapOptions/SoapOptions.php | 32 +++++++++++++------ .../SoapCommon/SoapOptionsBuilder.php | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/BeSimple/SoapCommon/SoapOptions/SoapOptions.php b/src/BeSimple/SoapCommon/SoapOptions/SoapOptions.php index 5b697b2..ad7702f 100644 --- a/src/BeSimple/SoapCommon/SoapOptions/SoapOptions.php +++ b/src/BeSimple/SoapCommon/SoapOptions/SoapOptions.php @@ -12,6 +12,8 @@ class SoapOptions { const SOAP_VERSION_1_1 = \SOAP_1_1; const SOAP_VERSION_1_2 = \SOAP_1_2; + const SOAP_CONNECTION_KEEP_ALIVE_ON = true; + const SOAP_CONNECTION_KEEP_ALIVE_OFF = false; const SOAP_ENCODING_UTF8 = 'UTF-8'; const SOAP_SINGLE_ELEMENT_ARRAYS_OFF = 0; const SOAP_CACHE_TYPE_NONE = Cache::TYPE_NONE; @@ -23,19 +25,21 @@ class SoapOptions const SOAP_ATTACHMENTS_TYPE_MTOM = Helper::ATTACHMENTS_TYPE_MTOM; const SOAP_ATTACHMENTS_TYPE_SWA = Helper::ATTACHMENTS_TYPE_SWA; - protected $soapVersion; - protected $encoding; - protected $soapFeatures; - protected $wsdlFile; - protected $wsdlCacheType; - protected $wsdlCacheDir; - protected $classMap; - protected $typeConverterCollection; - protected $attachmentType; + private $soapVersion; + private $encoding; + private $connectionKeepAlive; + private $soapFeatures; + private $wsdlFile; + private $wsdlCacheType; + private $wsdlCacheDir; + private $classMap; + private $typeConverterCollection; + private $attachmentType; /** - * @param SoapOptions::SOAP_VERSION_1_1|SoapOptions::SOAP_VERSION_1_2 $soapVersion + * @param int $soapVersion = SoapOptions::SOAP_VERSION_1_1|SoapOptions::SOAP_VERSION_1_2 * @param string $encoding = SoapOptions::SOAP_ENCODING_UTF8 + * @param bool $connectionKeepAlive = SoapOptions::SOAP_CONNECTION_KEEP_ALIVE_ON|SoapOptions::SOAP_CONNECTION_KEEP_ALIVE_OFF * @param SoapFeatures $features * @param string $wsdlFile * @param int $wsdlCacheType = SoapOptions::SOAP_CACHE_TYPE_NONE|SoapOptions::SOAP_CACHE_TYPE_MEMORY|SoapOptions::SOAP_CACHE_TYPE_DISK|SoapOptions::SOAP_CACHE_TYPE_DISK_MEMORY @@ -47,6 +51,7 @@ class SoapOptions public function __construct( $soapVersion, $encoding, + $connectionKeepAlive, SoapFeatures $features, $wsdlFile, $wsdlCacheType, @@ -57,6 +62,7 @@ class SoapOptions ) { $this->soapVersion = $soapVersion; $this->encoding = $encoding; + $this->connectionKeepAlive = $connectionKeepAlive; $this->soapFeatures = $features; $this->wsdlFile = $wsdlFile; $this->wsdlCacheType = $wsdlCacheType; @@ -75,6 +81,11 @@ class SoapOptions return $this->encoding; } + public function isConnectionKeepAlive() + { + return $this->connectionKeepAlive; + } + public function getWsdlFile() { return $this->wsdlFile; @@ -135,6 +146,7 @@ class SoapOptions 'cache_wsdl' => $this->getWsdlCacheType(), 'classmap' => $this->getClassMap()->getAll(), 'typemap' => $this->getTypeConverterCollection()->getTypemap(), + 'keep_alive' => $this->isConnectionKeepAlive(), ]; if ($this->hasWsdlCacheDir()) { $optionsAsArray['wsdl_cache_dir'] = $this->getWsdlCacheDir(); diff --git a/src/BeSimple/SoapCommon/SoapOptionsBuilder.php b/src/BeSimple/SoapCommon/SoapOptionsBuilder.php index f61e3ac..f79051c 100644 --- a/src/BeSimple/SoapCommon/SoapOptionsBuilder.php +++ b/src/BeSimple/SoapCommon/SoapOptionsBuilder.php @@ -57,6 +57,7 @@ class SoapOptionsBuilder $soapOptions = new SoapOptions( SoapOptions::SOAP_VERSION_1_2, SoapOptions::SOAP_ENCODING_UTF8, + SoapOptions::SOAP_CONNECTION_KEEP_ALIVE_OFF, new SoapFeatures([ SoapFeatures::SINGLE_ELEMENT_ARRAYS ]),