Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from lku/feature/missing-client-options
Browse files Browse the repository at this point in the history
Add support for new SoapClient option: keep_alive and ssl_method
  • Loading branch information
weierophinney committed Jun 23, 2015
2 parents b787610 + 4b4bbf5 commit e3db1f8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
62 changes: 62 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ class Client implements ServerClient
*/
protected $wsdl = null;

/**
* Whether to send the "Connection: Keep-Alive" header (true) or "Connection: close" header (false)
* Available since PHP 5.4.0
* @var bool
*/
protected $keepAlive;

/**
* One of SOAP_SSL_METHOD_TLS, SOAP_SSL_METHOD_SSLv2, SOAP_SSL_METHOD_SSLv3 or SOAP_SSL_METHOD_SSLv23
* Available since PHP 5.5.0
* @var int
*/
protected $sslMethod;

/**#@+
* @var string
*/
Expand Down Expand Up @@ -275,6 +289,16 @@ public function setOptions($options)
$this->connectionTimeout = $value;
break;

case 'keepalive':
case 'keep_alive':
$this->setKeepAlive($value);
break;

case 'sslmethod':
case 'ssl_method':
$this->setSslMethod($value);
break;

default:
throw new Exception\InvalidArgumentException('Unknown SOAP client option');
}
Expand Down Expand Up @@ -315,6 +339,8 @@ public function getOptions()
$options['cache_wsdl'] = $this->getWSDLCache();
$options['features'] = $this->getSoapFeatures();
$options['user_agent'] = $this->getUserAgent();
$options['keep_alive'] = $this->getKeepAlive();
$options['ssl_method'] = $this->getSslMethod();

foreach ($options as $key => $value) {
/*
Expand Down Expand Up @@ -1210,4 +1236,40 @@ public function setCookie($cookieName, $cookieValue=null)
$soapClient->__setCookie($cookieName, $cookieValue);
return $this;
}

/**
* @return boolean
*/
public function getKeepAlive()
{
return $this->keepAlive;
}

/**
* @param boolean $keepAlive
* @return self
*/
public function setKeepAlive($keepAlive)
{
$this->keepAlive = (bool) $keepAlive;
return $this;
}

/**
* @return int
*/
public function getSslMethod()
{
return $this->sslMethod;
}

/**
* @param int $sslMethod
* @return self
*/
public function setSslMethod($sslMethod)
{
$this->sslMethod = $sslMethod;
return $this;
}
}
12 changes: 9 additions & 3 deletions test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public function testSetOptions()
'features' => 4,

'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
'typemap' => $typeMap
'typemap' => $typeMap,
'keep_alive' => true,
'ssl_method' => 3,
];

$client->setOptions($nonWSDLOptions);
Expand Down Expand Up @@ -112,7 +114,9 @@ public function testSetOptions()
'stream_context' => $ctx,

'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
'typemap' => $typeMap
'typemap' => $typeMap,
'keep_alive' => true,
'ssl_method' => 3,
];

$client1->setOptions($wsdlOptions);
Expand Down Expand Up @@ -163,7 +167,9 @@ public function testGetOptions()
'passphrase' => 'some pass phrase',

'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
'typemap' => $typeMap
'typemap' => $typeMap,
'keep_alive' => true,
'ssl_method' => 3,
];

$client->setOptions($options);
Expand Down

0 comments on commit e3db1f8

Please sign in to comment.