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
This commit is contained in:
Petr Bechyně 2016-11-24 12:47:01 +01:00
parent 1224f5f40f
commit 51d1abab48
2 changed files with 23 additions and 10 deletions

View File

@ -12,6 +12,8 @@ class SoapOptions
{ {
const SOAP_VERSION_1_1 = \SOAP_1_1; const SOAP_VERSION_1_1 = \SOAP_1_1;
const SOAP_VERSION_1_2 = \SOAP_1_2; 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_ENCODING_UTF8 = 'UTF-8';
const SOAP_SINGLE_ELEMENT_ARRAYS_OFF = 0; const SOAP_SINGLE_ELEMENT_ARRAYS_OFF = 0;
const SOAP_CACHE_TYPE_NONE = Cache::TYPE_NONE; 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_MTOM = Helper::ATTACHMENTS_TYPE_MTOM;
const SOAP_ATTACHMENTS_TYPE_SWA = Helper::ATTACHMENTS_TYPE_SWA; const SOAP_ATTACHMENTS_TYPE_SWA = Helper::ATTACHMENTS_TYPE_SWA;
protected $soapVersion; private $soapVersion;
protected $encoding; private $encoding;
protected $soapFeatures; private $connectionKeepAlive;
protected $wsdlFile; private $soapFeatures;
protected $wsdlCacheType; private $wsdlFile;
protected $wsdlCacheDir; private $wsdlCacheType;
protected $classMap; private $wsdlCacheDir;
protected $typeConverterCollection; private $classMap;
protected $attachmentType; 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 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 SoapFeatures $features
* @param string $wsdlFile * @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 * @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( public function __construct(
$soapVersion, $soapVersion,
$encoding, $encoding,
$connectionKeepAlive,
SoapFeatures $features, SoapFeatures $features,
$wsdlFile, $wsdlFile,
$wsdlCacheType, $wsdlCacheType,
@ -57,6 +62,7 @@ class SoapOptions
) { ) {
$this->soapVersion = $soapVersion; $this->soapVersion = $soapVersion;
$this->encoding = $encoding; $this->encoding = $encoding;
$this->connectionKeepAlive = $connectionKeepAlive;
$this->soapFeatures = $features; $this->soapFeatures = $features;
$this->wsdlFile = $wsdlFile; $this->wsdlFile = $wsdlFile;
$this->wsdlCacheType = $wsdlCacheType; $this->wsdlCacheType = $wsdlCacheType;
@ -75,6 +81,11 @@ class SoapOptions
return $this->encoding; return $this->encoding;
} }
public function isConnectionKeepAlive()
{
return $this->connectionKeepAlive;
}
public function getWsdlFile() public function getWsdlFile()
{ {
return $this->wsdlFile; return $this->wsdlFile;
@ -135,6 +146,7 @@ class SoapOptions
'cache_wsdl' => $this->getWsdlCacheType(), 'cache_wsdl' => $this->getWsdlCacheType(),
'classmap' => $this->getClassMap()->getAll(), 'classmap' => $this->getClassMap()->getAll(),
'typemap' => $this->getTypeConverterCollection()->getTypemap(), 'typemap' => $this->getTypeConverterCollection()->getTypemap(),
'keep_alive' => $this->isConnectionKeepAlive(),
]; ];
if ($this->hasWsdlCacheDir()) { if ($this->hasWsdlCacheDir()) {
$optionsAsArray['wsdl_cache_dir'] = $this->getWsdlCacheDir(); $optionsAsArray['wsdl_cache_dir'] = $this->getWsdlCacheDir();

View File

@ -57,6 +57,7 @@ class SoapOptionsBuilder
$soapOptions = new SoapOptions( $soapOptions = new SoapOptions(
SoapOptions::SOAP_VERSION_1_2, SoapOptions::SOAP_VERSION_1_2,
SoapOptions::SOAP_ENCODING_UTF8, SoapOptions::SOAP_ENCODING_UTF8,
SoapOptions::SOAP_CONNECTION_KEEP_ALIVE_OFF,
new SoapFeatures([ new SoapFeatures([
SoapFeatures::SINGLE_ELEMENT_ARRAYS SoapFeatures::SINGLE_ELEMENT_ARRAYS
]), ]),