This commit is contained in:
Andreas Schamberger 2011-10-02 12:23:59 +02:00
parent 06ff1ab707
commit 3040718c9d
3 changed files with 160 additions and 228 deletions

View File

@ -8,7 +8,7 @@
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*
*
* @link https://github.com/BeSimple/BeSimpleSoapClient
*/
@ -55,11 +55,10 @@ class Curl
* @param array $options
* @param int $followLocationMaxRedirects
*/
public function __construct( array $options, $followLocationMaxRedirects = 10 )
public function __construct(array $options, $followLocationMaxRedirects = 10)
{
// set the default HTTP user agent
if ( !isset( $options['user_agent'] ) )
{
if (!isset($options['user_agent'])) {
$options['user_agent'] = self::USER_AGENT;
}
$this->followLocationMaxRedirects = $followLocationMaxRedirects;
@ -75,34 +74,28 @@ class Curl
CURLOPT_HEADER => true,
CURLOPT_USERAGENT => $options['user_agent'],
CURLINFO_HEADER_OUT => true,
);
curl_setopt_array( $this->ch, $curlOptions );
if ( isset( $options['compression'] ) && !( $options['compression'] & SOAP_COMPRESSION_ACCEPT ) )
{
curl_setopt( $this->ch, CURLOPT_ENCODING, 'identity' );
);
curl_setopt_array($this->ch, $curlOptions);
if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) {
curl_setopt($this->ch, CURLOPT_ENCODING, 'identity');
}
if ( isset( $options['connection_timeout'] ) )
{
curl_setopt( $this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout'] );
if (isset($options['connection_timeout'])) {
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']);
}
if ( isset( $options['proxy_host'] ) )
{
$port = isset( $options['proxy_port'] ) ? $options['proxy_port'] : 8080;
curl_setopt( $this->ch, CURLOPT_PROXY, $options['proxy_host'] . ':' . $port );
if (isset($options['proxy_host'])) {
$port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080;
curl_setopt($this->ch, CURLOPT_PROXY, $options['proxy_host'] . ':' . $port);
}
if ( isset( $options['proxy_user'] ) )
{
curl_setopt( $this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password'] );
if (isset($options['proxy_user'])) {
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
}
if ( isset( $options['login'] ) )
{
curl_setopt( $this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
curl_setopt( $this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password'] );
if (isset($options['login'])) {
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);
}
if ( isset( $options['local_cert'] ) )
{
curl_setopt( $this->ch, CURLOPT_SSLCERT, $options['local_cert'] );
curl_setopt( $this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase'] );
if (isset($options['local_cert'])) {
curl_setopt($this->ch, CURLOPT_SSLCERT, $options['local_cert']);
curl_setopt($this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase']);
}
}
@ -111,7 +104,7 @@ class Curl
*/
public function __destruct()
{
curl_close( $this->ch );
curl_close($this->ch);
}
/**
@ -123,24 +116,22 @@ class Curl
* @param array $requestHeaders
* @return bool
*/
public function exec( $location, $request = null, $requestHeaders = array() )
public function exec($location, $request = null, $requestHeaders = array())
{
curl_setopt( $this->ch, CURLOPT_URL, $location);
curl_setopt($this->ch, CURLOPT_URL, $location);
if ( !is_null( $request ) )
{
curl_setopt( $this->ch, CURLOPT_POST, true );
curl_setopt( $this->ch, CURLOPT_POSTFIELDS, $request );
if (!is_null($request)) {
curl_setopt($this->ch, CURLOPT_POST, true);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $request);
}
if ( count( $requestHeaders ) > 0 )
{
curl_setopt( $this->ch, CURLOPT_HTTPHEADER, $requestHeaders );
if (count($requestHeaders) > 0) {
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $requestHeaders);
}
$this->response = $this->execManualRedirect( $this->followLocationMaxRedirects );
$this->response = $this->execManualRedirect($this->followLocationMaxRedirects);
return ( $this->response === false ) ? false : true;
return ($this->response === false) ? false : true;
}
/**
@ -152,43 +143,37 @@ class Curl
* @param int $redirects
* @return mixed
*/
private function execManualRedirect( $redirects = 0 )
private function execManualRedirect($redirects = 0)
{
if ( $redirects > $this->followLocationMaxRedirects )
{
if ($redirects > $this->followLocationMaxRedirects) {
// TODO Redirection limit reached, aborting
return false;
}
curl_setopt( $this->ch, CURLOPT_HEADER, true );
curl_setopt( $this->ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec( $this->ch );
$httpResponseCode = curl_getinfo( $this->ch, CURLINFO_HTTP_CODE );
if ( $httpResponseCode == 307 )
{
$headerSize = curl_getinfo( $this->ch, CURLINFO_HEADER_SIZE );
$header = substr( $response, 0, $headerSize );
curl_setopt($this->ch, CURLOPT_HEADER, true);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($this->ch);
$httpResponseCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
if ($httpResponseCode == 307) {
$headerSize = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $headerSize);
$matches = array();
preg_match( '/Location:(.*?)\n/', $header, $matches );
$url = trim( array_pop( $matches ) );
preg_match('/Location:(.*?)\n/', $header, $matches);
$url = trim(array_pop($matches));
// @parse_url to suppress E_WARNING for invalid urls
if ( ( $url = @parse_url( $url ) ) !== false )
{
$lastUrl = parse_url( curl_getinfo( $this->ch, CURLINFO_EFFECTIVE_URL ) );
if ( !isset( $url['scheme'] ) )
{
if (($url = @parse_url($url)) !== false) {
$lastUrl = parse_url(curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL));
if (!isset($url['scheme'])) {
$url['scheme'] = $lastUrl['scheme'];
}
if ( !isset( $url['host'] ) )
{
if (!isset($url['host'])) {
$url['host'] = $lastUrl['host'];
}
if ( !isset( $url['path'] ) )
{
if (!isset($url['path'])) {
$url['path'] = $lastUrl['path'];
}
$newUrl = $url['scheme'] . '://' . $url['host'] . $url['path'] . ( $url['query'] ? '?' . $url['query'] : '' );
curl_setopt( $this->ch, CURLOPT_URL, $newUrl );
return $this->execManualRedirect( $redirects++ );
$newUrl = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query'] ? '?' . $url['query'] : '');
curl_setopt($this->ch, CURLOPT_URL, $newUrl);
return $this->execManualRedirect($redirects++);
}
}
return $response;
@ -229,7 +214,7 @@ class Curl
67 => 'Could not connect to host', //CURLE_LOGIN_DENIED
77 => 'Could not connect to host', //CURLE_SSL_CACERT_BADFILE
80 => 'Error Fetching http body, No Content-Length, connection closed or chunked data', //CURLE_SSL_SHUTDOWN_FAILED
);
);
}
/**
@ -240,12 +225,11 @@ class Curl
public function getErrorMessage()
{
$errorCodeMapping = $this->getErrorCodeMapping();
$errorNumber = curl_errno( $this->ch );
if ( isset( $errorCodeMapping[$errorNumber] ) )
{
$errorNumber = curl_errno($this->ch);
if (isset($errorCodeMapping[$errorNumber])) {
return $errorCodeMapping[$errorNumber];
}
return curl_error( $this->ch );
return curl_error($this->ch);
}
/**
@ -255,7 +239,7 @@ class Curl
*/
public function getRequestHeaders()
{
return curl_getinfo( $this->ch, CURLINFO_HEADER_OUT );
return curl_getinfo($this->ch, CURLINFO_HEADER_OUT);
}
/**
@ -275,8 +259,8 @@ class Curl
*/
public function getResponseBody()
{
$headerSize = curl_getinfo( $this->ch, CURLINFO_HEADER_SIZE );
return substr( $this->response, $headerSize );
$headerSize = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE);
return substr($this->response, $headerSize);
}
/**
@ -286,7 +270,7 @@ class Curl
*/
public function getResponseContentType()
{
return curl_getinfo( $this->ch, CURLINFO_CONTENT_TYPE );
return curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
}
/**
@ -296,8 +280,8 @@ class Curl
*/
public function getResponseHeaders()
{
$headerSize = curl_getinfo( $this->ch, CURLINFO_HEADER_SIZE );
return substr( $this->response, 0, $headerSize );
$headerSize = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE);
return substr($this->response, 0, $headerSize);
}
/**
@ -307,7 +291,7 @@ class Curl
*/
public function getResponseStatusCode()
{
return curl_getinfo( $this->ch, CURLINFO_HTTP_CODE );
return curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
}
/**
@ -317,7 +301,7 @@ class Curl
*/
public function getResponseStatusMessage()
{
preg_match( '/HTTP\/(1\.[0-1]+) ([0-9]{3}) (.*)/', $this->response, $matches );
return trim( array_pop( $matches ) );
preg_match('/HTTP\/(1\.[0-1]+) ([0-9]{3}) (.*)/', $this->response, $matches);
return trim(array_pop($matches));
}
}

View File

@ -8,7 +8,7 @@
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*
*
* @link https://github.com/BeSimple/BeSimpleSoapClient
*/
@ -171,12 +171,11 @@ class Helper
* @param string $errline
* @throws ErrorException
*/
public static function exceptionErrorHandler( $errno, $errstr, $errfile, $errline )
public static function exceptionErrorHandler($errno, $errstr, $errfile, $errline)
{
// don't throw exception for errors suppresed with @
if ( error_reporting() != 0 )
{
throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
if (error_reporting() != 0) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}
}
@ -191,19 +190,19 @@ class Helper
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
);
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
/**
@ -214,21 +213,17 @@ class Helper
public static function getCurrentUrl()
{
$url = '';
if ( isset( $_SERVER['HTTPS'] ) &&
( strtolower( $_SERVER['HTTPS'] ) === 'on' || $_SERVER['HTTPS'] === '1' ) )
{
if (isset($_SERVER['HTTPS']) &&
(strtolower($_SERVER['HTTPS']) === 'on' || $_SERVER['HTTPS'] === '1')) {
$url .= 'https://';
}
else
{
} else {
$url .= 'http://';
}
$url .= isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : '';
if ( isset( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] != 80 )
{
$url .= isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
$url .= ":{$_SERVER['SERVER_PORT']}";
}
$url .= isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';
$url .= isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
return $url;
}
@ -238,14 +233,11 @@ class Helper
* @param int $version SOAP_1_1|SOAP_1_2
* @return string
*/
public static function getSoapNamespace( $version )
public static function getSoapNamespace($version)
{
if ( $version === SOAP_1_2 )
{
if ($version === SOAP_1_2) {
return self::NS_SOAP_1_2;
}
else
{
} else {
return self::NS_SOAP_1_1;
}
}
@ -256,14 +248,11 @@ class Helper
* @param string $namespace NS_SOAP_1_1|NS_SOAP_1_2
* @return int SOAP_1_1|SOAP_1_2
*/
public static function getSoapVersionFromNamespace( $namespace )
public static function getSoapVersionFromNamespace($namespace)
{
if ( $namespace === self::NS_SOAP_1_2 )
{
if ($namespace === self::NS_SOAP_1_2) {
return SOAP_1_2;
}
else
{
} else {
return SOAP_1_1;
}
}
@ -279,46 +268,38 @@ class Helper
* @param \ass\Soap\WsdlHandler $wsdlHandler
* @return string
*/
public static function runPlugins( array $plugins, $requestType, $xml, $location = null, $action = null, \ass\Soap\WsdlHandler $wsdlHandler = null )
public static function runPlugins(array $plugins, $requestType, $xml, $location = null, $action = null, \ass\Soap\WsdlHandler $wsdlHandler = null)
{
if ( count( $plugins ) > 0 )
{
if (count($plugins) > 0) {
// instantiate new dom object
$dom = new \DOMDocument( '1.0' );
$dom = new \DOMDocument('1.0');
// format the XML if option is set
$dom->formatOutput = self::$formatXmlOutput;
$dom->loadXML( $xml );
$dom->loadXML($xml);
$params = array(
$dom,
$location,
$action,
$wsdlHandler
);
if ( $requestType == self::REQUEST )
{
if ($requestType == self::REQUEST) {
$callMethod = 'modifyRequest';
}
else
{
} else {
$callMethod = 'modifyResponse';
}
// modify dom
foreach( $plugins AS $plugin )
{
if ( $plugin instanceof \ass\Soap\Plugin )
{
call_user_func_array( array( $plugin, $callMethod ), $params );
foreach($plugins AS $plugin) {
if ($plugin instanceof \ass\Soap\Plugin) {
call_user_func_array(array($plugin, $callMethod), $params);
}
}
// return the modified xml document
return $dom->saveXML();
}
// format the XML if option is set
elseif ( self::$formatXmlOutput === true )
{
$dom = new \DOMDocument( '1.0' );
} elseif (self::$formatXmlOutput === true) {
$dom = new \DOMDocument('1.0');
$dom->formatOutput = true;
$dom->loadXML( $xml );
$dom->loadXML($xml);
return $dom->saveXML();
}
return $xml;
@ -329,16 +310,13 @@ class Helper
*
* @param boolean $reset
*/
public static function setCustomErrorHandler( $reset = false )
public static function setCustomErrorHandler($reset = false)
{
if ( $reset === true && !is_null( self::$previousErrorHandler ) )
{
set_error_handler( self::$previousErrorHandler );
if ($reset === true && !is_null(self::$previousErrorHandler)) {
set_error_handler(self::$previousErrorHandler);
self::$previousErrorHandler = null;
}
else
{
self::$previousErrorHandler = set_error_handler( 'ass\\Soap\\Helper::exceptionErrorHandler' );
} else {
self::$previousErrorHandler = set_error_handler('ass\\Soap\\Helper::exceptionErrorHandler');
}
return self::$previousErrorHandler;
}
@ -351,13 +329,13 @@ class Helper
* @param string $contentType
* @return string
*/
public static function makeSoapAttachmentDataString( $contentId, $contentType )
public static function makeSoapAttachmentDataString($contentId, $contentType)
{
$parameter = array(
'cid' => $contentId,
'type' => $contentType,
);
return 'SOAP-MIME-ATTACHMENT:' . http_build_query( $parameter, null, '&' );
return 'SOAP-MIME-ATTACHMENT:' . http_build_query($parameter, null, '&');
}
/**
@ -367,12 +345,12 @@ class Helper
* @param string $dataString
* @return array(string=>string)
*/
public static function parseSoapAttachmentDataString( $dataString )
public static function parseSoapAttachmentDataString($dataString)
{
$dataString = substr( $dataString, 21 );
$dataString = substr($dataString, 21);
// get all data
$data = array();
parse_str( $dataString, $data );
parse_str($dataString, $data);
return $data;
}
@ -382,15 +360,12 @@ class Helper
*
* @param string $header
*/
public static function setHttpStatusHeader( $header )
public static function setHttpStatusHeader($header)
{
if ( substr( php_sapi_name(), 0, 3 ) == 'cgi' )
{
header( 'Status: ' . $header );
}
else
{
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $header );
if ('cgi' == substr(php_sapi_name(), 0, 3)) {
header('Status: ' . $header);
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $header);
}
}
}

View File

@ -8,16 +8,16 @@
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*
*
* @link https://github.com/BeSimple/BeSimpleSoapClient
*/
namespace BeSimple\SoapClient;
/**
* Extended SoapClient that uses a a cURL wrapper for all underlying HTTP
* requests in order to use proper authentication for all requests. This also
* adds NTLM support. A custom WSDL downloader resolves remote xsd:includes and
* Extended SoapClient that uses a a cURL wrapper for all underlying HTTP
* requests in order to use proper authentication for all requests. This also
* adds NTLM support. A custom WSDL downloader resolves remote xsd:includes and
* allows caching of all remote referenced items.
*
* @author Andreas Schamberger
@ -73,37 +73,30 @@ class SoapClient extends \SoapClient
* @param string $wsdl
* @param array(string=>mixed) $options
*/
public function __construct( $wsdl, array $options = array(), TypeConverterCollection $converters = null )
public function __construct($wsdl, array $options = array(), TypeConverterCollection $converters = null)
{
// we want the exceptions option to be set
$options['exceptions'] = true;
// set custom error handler that converts all php errors to ErrorExceptions
Helper::setCustomErrorHandler();
// we want to make sure we have the soap version to rely on it later
if ( !isset( $options['soap_version'] ) )
{
if (!isset($options['soap_version'])) {
$options['soap_version'] = SOAP_1_1;
}
// we want to make sure we have the features option
if ( !isset( $options['features'] ) )
{
if (!isset($options['features'])) {
$options['features'] = 0;
}
// set default option to resolve xsd includes
if ( !isset( $options['resolve_xsd_includes'] ) )
{
if (!isset($options['resolve_xsd_includes'])) {
$options['resolve_xsd_includes'] = true;
}
// add type converters from TypeConverterCollection
if ( !is_null( $converters ) )
{
if (!is_null($converters)) {
$convertersTypemap = $converters->getTypemap();
if ( isset( $options['typemap'] ) )
{
$options['typemap'] = array_merge( $options['typemap'], $convertersTypemap );
}
else
{
if (isset($options['typemap'])) {
$options['typemap'] = array_merge($options['typemap'], $convertersTypemap);
} else {
$options['typemap'] = $convertersTypemap;
}
}
@ -115,8 +108,8 @@ class SoapClient extends \SoapClient
$options['cache_wsdl'] = WSDL_CACHE_NONE;
// load WSDL and run parent constructor
// can't be loaded later as we need it already in the parent constructor
$this->wsdlFile = $this->loadWsdl( $wsdl );
parent::__construct( $this->wsdlFile, $options );
$this->wsdlFile = $this->loadWsdl($wsdl);
parent::__construct($this->wsdlFile, $options);
}
/**
@ -127,46 +120,40 @@ class SoapClient extends \SoapClient
* @param string $action
* @return string
*/
private function __doHttpRequest( $request, $location, $action )
private function __doHttpRequest($request, $location, $action)
{
// $request is if unmodified from SoapClient not a php string type!
$request = (string)$request;
if ( $this->options['soap_version'] == SOAP_1_2 )
{
if ($this->options['soap_version'] == SOAP_1_2) {
$headers = array(
'Content-Type: application/soap+xml; charset=utf-8',
);
}
else
{
);
} else {
$headers = array(
'Content-Type: text/xml; charset=utf-8',
);
);
}
// add SOAPAction header
$headers[] = 'SOAPAction: "' . $action . '"';
// new curl object for request
$curl = new Curl( $this->options );
$curl = new Curl($this->options);
// execute request
$responseSuccessfull = $curl->exec( $location, $request, $headers );
$responseSuccessfull = $curl->exec($location, $request, $headers);
// tracing enabled: store last request header and body
if ( isset( $this->options['trace'] ) && $this->options['trace'] === true )
{
if (isset($this->options['trace']) && $this->options['trace'] === true) {
$this->lastRequestHeaders = $curl->getRequestHeaders();
$this->lastRequest = $request;
}
// in case of an error while making the http request throw a soapFault
if ( $responseSuccessfull === false )
{
if ($responseSuccessfull === false) {
// get error message from curl
$faultstring = $curl->getErrorMessage();
// destruct curl object
unset( $curl );
throw new \SoapFault( 'HTTP', $faultstring );
unset($curl);
throw new \SoapFault('HTTP', $faultstring);
}
// tracing enabled: store last response header and body
if ( isset( $this->options['trace'] ) && $this->options['trace'] === true )
{
if (isset($this->options['trace']) && $this->options['trace'] === true) {
$this->lastResponseHeaders = $curl->getResponseHeaders();
$this->lastResponse = $curl->getResponseBody();
}
@ -174,43 +161,32 @@ class SoapClient extends \SoapClient
// check if we do have a proper soap status code (if not soapfault)
// // TODO
// $responseStatusCode = $curl->getResponseStatusCode();
// if ( $responseStatusCode >= 400 )
// {
// if ($responseStatusCode >= 400) {
// $isError = 0;
// $response = trim( $response );
// if ( strlen( $response ) == 0 )
// {
// $response = trim($response);
// if (strlen($response) == 0) {
// $isError = 1;
// }
// else
// {
// } else {
// $contentType = $curl->getResponseContentType();
// if ( $contentType != 'application/soap+xml'
// && $contentType != 'application/soap+xml' )
// {
// if ( strncmp( $response , "<?xml", 5 ) )
// {
// if ($contentType != 'application/soap+xml'
// && $contentType != 'application/soap+xml') {
// if (strncmp($response , "<?xml", 5)) {
// $isError = 1;
// }
// }
// }
// if ( $isError == 1 )
// {
// throw new \SoapFault( 'HTTP', $curl->getResponseStatusMessage() );
// if ($isError == 1) {
// throw new \SoapFault('HTTP', $curl->getResponseStatusMessage());
// }
// }
// // TODO
// elseif ( $responseStatusCode != 200 && $responseStatusCode != 202 )
// {
// $dom = new \DOMDocument( '1.0' );
// $dom->loadXML( $response );
// if ( $dom->getElementsByTagNameNS( $dom->documentElement->namespaceURI, 'Fault' )->length == 0 )
// {
// throw new \SoapFault( 'HTTP', 'HTTP response status must be 200 or 202' );
// } elseif ($responseStatusCode != 200 && $responseStatusCode != 202) {
// $dom = new \DOMDocument('1.0');
// $dom->loadXML($response);
// if ($dom->getElementsByTagNameNS($dom->documentElement->namespaceURI, 'Fault')->length == 0) {
// throw new \SoapFault('HTTP', 'HTTP response status must be 200 or 202');
// }
// }
// destruct curl object
unset( $curl );
unset($curl);
return $response;
}
@ -224,10 +200,10 @@ class SoapClient extends \SoapClient
* @param int $one_way 0|1
* @return string
*/
public function __doRequest( $request, $location, $action, $version, $one_way = 0 )
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
// http request
$response = $this->__doHttpRequest( $request, $location, $action );
$response = $this->__doHttpRequest($request, $location, $action);
// return SOAP response to ext/soap
return $response;
}
@ -281,16 +257,13 @@ class SoapClient extends \SoapClient
* @param string $wsdl
* @return string
*/
private function loadWsdl( $wsdl )
private function loadWsdl($wsdl)
{
$wsdlDownloader = new WsdlDownloader( $this->options );
try
{
$cacheFileName = $wsdlDownloader->download( $wsdl );
}
catch ( \RuntimeException $e )
{
throw new \SoapFault( 'WSDL', "SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl . "' : failed to load external entity \"" . $wsdl . "\"" );
$wsdlDownloader = new WsdlDownloader($this->options);
try {
$cacheFileName = $wsdlDownloader->download($wsdl);
} catch (\RuntimeException $e) {
throw new \SoapFault('WSDL', "SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl . "' : failed to load external entity \"" . $wsdl . "\"");
}
return $cacheFileName;
}