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

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into hot…
Browse files Browse the repository at this point in the history
…fix/cache-empty-namespace
  • Loading branch information
Show file tree
Hide file tree
Showing 13 changed files with 754 additions and 159 deletions.
3 changes: 2 additions & 1 deletion src/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function getServiceName()


/**
* Set the location at which the WSDL file will be availabe.
* Set the location at which the WSDL file will be available.
*
* @param Uri\Uri|string $uri
* @return AutoDiscover
Expand Down Expand Up @@ -375,6 +375,7 @@ protected function _generateWsdl(array $reflectionMethods)
$uri = $this->getUri();

$serviceName = $this->getServiceName();
/** @var Wsdl $wsdl */
$wsdl = new $this->wsdlClass($serviceName, $uri, $this->strategy, $this->classMap);

// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
Expand Down
27 changes: 14 additions & 13 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function getOptions()
*
* @param int $version One of the SOAP_1_1 or SOAP_1_2 constants
* @return Client
* @throws Exception\ExceptionInterface with invalid soap version argument
* @throws Exception\InvalidArgumentException with invalid soap version argument
*/
public function setSoapVersion($version)
{
Expand Down Expand Up @@ -347,7 +347,7 @@ public function getSoapVersion()
*
* @param array $classmap
* @return Client
* @throws Exception\ExceptionInterface for any invalid class in the class map
* @throws Exception\InvalidArgumentException for any invalid class in the class map
*/
public function setClassmap(array $classmap)
{
Expand Down Expand Up @@ -378,7 +378,7 @@ public function getClassmap()
*
* @param string $encoding
* @return Client
* @throws Exception\ExceptionInterface with invalid encoding argument
* @throws Exception\InvalidArgumentException with invalid encoding argument
*/
public function setEncoding($encoding)
{
Expand Down Expand Up @@ -408,7 +408,7 @@ public function getEncoding()
*
* @param string $urn
* @return boolean
* @throws Exception\ExceptionInterface on invalid URN
* @throws Exception\InvalidArgumentException on invalid URN
*/
public function validateUrn($urn)
{
Expand Down Expand Up @@ -484,7 +484,7 @@ public function getLocation()
*
* @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants
* @return Client
* @throws Exception\ExceptionInterface with invalid style argument
* @throws Exception\InvalidArgumentException with invalid style argument
*/
public function setStyle($style)
{
Expand Down Expand Up @@ -514,7 +514,7 @@ public function getStyle()
*
* @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants
* @return Client
* @throws Exception\ExceptionInterface with invalid message encoding method argument
* @throws Exception\InvalidArgumentException with invalid message encoding method argument
*/
public function setEncodingMethod($use)
{
Expand Down Expand Up @@ -622,7 +622,7 @@ public function getProxyHost()
*/
public function setProxyPort($proxyPort)
{
$this->proxy_port = (int)$proxyPort;
$this->proxy_port = (int) $proxyPort;

$this->soapClient = null;

Expand Down Expand Up @@ -684,7 +684,7 @@ public function setProxyPassword($proxyPassword)
*
* @param string $localCert local certificate path
* @return Client
* @throws Exception\ExceptionInterface with invalid local certificate path argument
* @throws Exception\InvalidArgumentException with invalid local certificate path argument
*/
public function setHttpsCertificate($localCert)
{
Expand Down Expand Up @@ -745,7 +745,7 @@ public function setCompressionOptions($compressionOptions)
if ($compressionOptions === null) {
$this->compression = null;
} else {
$this->compression = (int)$compressionOptions;
$this->compression = (int) $compressionOptions;
}
$this->soapClient = null;

Expand Down Expand Up @@ -777,6 +777,7 @@ public function getProxyPassword()
*
* @param resource $context
* @return Client
* @throws Exception\InvalidArgumentException if $context is not a valid stream resource
*/
public function setStreamContext($context)
{
Expand Down Expand Up @@ -833,7 +834,7 @@ public function setWSDLCache($caching)
if ($caching === null) {
$this->cache_wsdl = null;
} else {
$this->cache_wsdl = (int)$caching;
$this->cache_wsdl = (int) $caching;
}
return $this;
}
Expand All @@ -859,7 +860,7 @@ public function setUserAgent($userAgent)
if ($userAgent === null) {
$this->user_agent = null;
} else {
$this->user_agent = (string)$userAgent;
$this->user_agent = (string) $userAgent;
}
return $this;
}
Expand Down Expand Up @@ -1108,7 +1109,7 @@ public function call($method, $params = array())
* Return a list of available functions
*
* @return array
* @throws Exception\ExceptionInterface
* @throws Exception\UnexpectedValueException
*/
public function getFunctions()
{
Expand All @@ -1131,7 +1132,7 @@ public function getFunctions()
* Return a list of SOAP types
*
* @return array
* @throws Exception\ExceptionInterface
* @throws Exception\UnexpectedValueException
*/
public function getTypes()
{
Expand Down
163 changes: 163 additions & 0 deletions src/Client/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

namespace Zend\Soap\Client;

use Zend\Http\Client\Adapter\Curl as CurlClient;
use Zend\Http\Response as HttpResponse;
use Zend\Soap\Client as SOAPClient;
use Zend\Soap\Client\Common as CommonClient;
use Zend\Soap\Exception;
use Zend\Uri\Http as HttpUri;

/**
* .NET SOAP client
Expand Down Expand Up @@ -42,6 +46,114 @@ public function __construct($wsdl = null, $options = null)
parent::__construct($wsdl, $options);
}

/**
* Do request proxy method.
*
* @param CommonClient $client Actual SOAP client.
* @param string $request The request body.
* @param string $location The SOAP URI.
* @param string $action The SOAP action to call.
* @param integer $version The SOAP version to use.
* @param integer $one_way (Optional) The number 1 if a response is not expected.
* @return string The XML SOAP response.
*/
public function _doRequest(CommonClient $client, $request, $location, $action, $version, $one_way = null)
{
if (!$this->useNtlm) {
return parent::_doRequest($client, $request, $location, $action, $version, $one_way);
}

$curlClient = $this->getCurlClient();
$headers = array('Content-Type' => 'text/xml; charset=utf-8',
'Method' => 'POST',
'SOAPAction' => '"' . $action . '"',
'User-Agent' => 'PHP-SOAP-CURL');
$uri = new HttpUri($location);

$curlClient->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_NTLM)
->setCurlOption(CURLOPT_SSL_VERIFYHOST, false)
->setCurlOption(CURLOPT_SSL_VERIFYPEER, false)
->setCurlOption(CURLOPT_USERPWD, $this->options['login'] . ':' . $this->options['password']);

// Perform the cURL request and get the response
$curlClient->connect($uri->getHost(), $uri->getPort());
$curlClient->write('POST', $uri, 1.1, $headers, $request);
$response = HttpResponse::fromString($curlClient->read());
$curlClient->close();

// Save headers
$this->lastRequestHeaders = $this->flattenHeaders($headers);
$this->lastResponseHeaders = $response->getHeaders()->toString();

// Return only the XML body
return $response->getBody();
}

/**
* Returns the cURL client that is being used.
*
* @return \Zend\Http\Client\Adapter\Curl The cURL client.
*/
public function getCurlClient()
{
if ($this->curlClient === null) {
$this->curlClient = new CurlClient();
}

return $this->curlClient;
}

/**
* Retrieve request headers.
*
* @return string Request headers.
*/
public function getLastRequestHeaders()
{
return $this->lastRequestHeaders;
}

/**
* Retrieve response headers (as string)
*
* @return string Response headers.
*/
public function getLastResponseHeaders()
{
return $this->lastResponseHeaders;
}

/**
* Sets the cURL client to use.
*
* @param CurlClient $curlClient The cURL client.
* @return self Fluent interface.
*/
public function setCurlClient(CurlClient $curlClient)
{
$this->curlClient = $curlClient;
return $this;
}

/**
* Sets options.
*
* Allows setting options as an associative array of option => value pairs.
*
* @param array|\Traversable $options Options.
* @throws \InvalidArgumentException If an unsupported option is passed.
* @return self Fluent interface.
*/
public function setOptions($options)
{
if (isset($options['authentication']) && $options['authentication'] === 'ntlm') {
$this->useNtlm = true;
unset($options['authentication']);
}

$this->options = $options;
return parent::setOptions($options);
}

/**
* Perform arguments pre-processing
Expand Down Expand Up @@ -79,4 +191,55 @@ protected function _preProcessResult($result)
return $result->$resultProperty;
}

/**
* Flattens an HTTP headers array into a string.
*
* @param array $headers The headers to flatten.
* @return string The headers string.
*/
private function flattenHeaders(array $headers)
{
$result = '';

foreach ($headers as $name => $value) {
$result .= $name . ': ' . $value . "\r\n";
}

return $result;
}

/**
* Curl HTTP client adapter.
*
* @var \Zend\Http\Client\Adapter\Curl
*/
private $curlClient = null;

/**
* The last request headers.
*
* @var string
*/
private $lastRequestHeaders = '';

/**
* The last response headers.
*
* @var string
*/
private $lastResponseHeaders = '';

/**
* SOAP client options.
*
* @var array
*/
private $options = array();

/**
* Should NTLM authentication be used?
*
* @var boolean
*/
private $useNtlm = false;
}
4 changes: 1 addition & 3 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ public function setOptions($options)
case 'wsdl':
$this->setWSDL($value);
break;
case 'featues':
trigger_error(__METHOD__ . ': the option "featues" is deprecated as of 1.10.x and will be removed with 2.0.0; use "features" instead', E_USER_NOTICE);
case 'features':
$this->setSoapFeatures($value);
break;
Expand Down Expand Up @@ -630,7 +628,7 @@ public function setPersistence($mode)
/**
* Get server persistence
*
* @return Server
* @return int
*/
public function getPersistence()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Server/DocumentLiteralWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function __call($method, $args)
protected function _parseArguments($method, $document)
{
$reflMethod = $this->reflection->getMethod($method);
/* @var \Zend\Server\Reflection\ReflectionParameter[] $params */
$params = array();
foreach ($reflMethod->getParameters() as $param) {
$params[$param->getName()] = $param;
Expand All @@ -133,7 +134,7 @@ protected function _parseArguments($method, $document)
if (!isset($params[$argName])) {
throw new UnexpectedValueException(sprintf(
"Received unknown argument %s which is not an argument to %s::%s",
get_class($this->object), $method
$argName, get_class($this->object), $method
));
}
$delegateArgs[$params[$argName]->getPosition()] = $argValue;
Expand Down
Loading

0 comments on commit 1386ed7

Please sign in to comment.