cvs: pear /SOAP Client.php WSDL.php package.xml
| From: | Jan Schneider | Date: | Mon, 19 Jun 2006 16:38:35 +0000 |
| Subject: | cvs: pear /SOAP Client.php WSDL.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-40820@lists.php.net to get a copy of this message | ||
yunosh Mon Jun 19 16:38:35 2006 UTC
Modified files:
/pear/SOAP package.xml Client.php WSDL.php
Log:
Allow to enable and disable WSDL caching and to set the cache directory in the client constructor.
http://cvs.php.net/viewvc.cgi/pear/SOAP/package.xml?r1=1.83&r2=1.84&diff_format=u Index: pear/SOAP/package.xml diff -u pear/SOAP/package.xml:1.83 pear/SOAP/package.xml:1.84 --- pear/SOAP/package.xml:1.83 Mon Jun 19 16:35:10 2006 +++ pear/SOAP/package.xml Mon Jun 19 16:38:35 2006 @@ -43,7 +43,8 @@ <state>beta</state> <version>0.9.5</version> <date>2006-99-99</date> - <notes>* Replace all invalid characters in label and variable name of the generated proxy code. (Bug 7493). + <notes>* Allow to enable and disable WSDL caching and to set the cache directory in the client constructor. +* Replace all invalid characters in label and variable name of the generated proxy code. (Bug 7493). * Fix subsequent failures if one transmission with a Transport class instance failed (Bug 7469).</notes> <filelist> <dir name="/" baseinstalldir="SOAP"> http://cvs.php.net/viewvc.cgi/pear/SOAP/Client.php?r1=1.79&r2=1.80&diff_format=u Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.79 pear/SOAP/Client.php:1.80 --- pear/SOAP/Client.php:1.79 Thu Jun 1 11:03:20 2006 +++ pear/SOAP/Client.php Mon Jun 19 16:38:35 2006 @@ -190,14 +190,16 @@ * * @access public * - * @param string $endpoint An URL. - * @param boolean $wsdl Whether the endpoint is a WSDL file. - * @param string $portName - * @param array $proxy_params Options for the HTTP_Request class (see - * HTTP/Request.php) + * @param string $endpoint An URL. + * @param boolean $wsdl Whether the endpoint is a WSDL file. + * @param string $portName The service's port name to use. + * @param array $proxy_params Options for the HTTP_Request class + * @see HTTP_Request + * @param boolean|string $cache Use WSDL caching? The cache directory if + * a string. */ function SOAP_Client($endpoint, $wsdl = false, $portName = false, - $proxy_params = array()) + $proxy_params = array(), $cache = false) { parent::SOAP_Base('Client'); @@ -216,7 +218,8 @@ $this->__endpointType = 'wsdl'; // instantiate wsdl class $this->_wsdl =& new SOAP_WSDL($this->_endpoint, - $this->__proxy_params); + $this->__proxy_params, + $cache); if ($this->_wsdl->fault) { $this->_raiseSoapFault($this->_wsdl->fault); } @@ -346,8 +349,8 @@ // Save the wire information for debugging. if ($this->__options['trace'] > 0) { - $this->__last_request =& $this->_soap_transport->outgoing_payload; - $this->__last_response =& $this->_soap_transport->incoming_payload; + $this->__last_request = $this->_soap_transport->outgoing_payload; + $this->__last_response = $this->_soap_transport->incoming_payload; $this->wire = $this->__get_wire(); } if ($this->_soap_transport->fault) { http://cvs.php.net/viewvc.cgi/pear/SOAP/WSDL.php?r1=1.89&r2=1.90&diff_format=u Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.89 pear/SOAP/WSDL.php:1.90 --- pear/SOAP/WSDL.php:1.89 Mon Jun 19 15:20:39 2006 +++ pear/SOAP/WSDL.php Mon Jun 19 16:38:35 2006 @@ -27,7 +27,6 @@ require_once 'HTTP/Request.php'; define('WSDL_CACHE_MAX_AGE', 43200); -define('WSDL_CACHE_USE', 0); // set to zero to turn off caching /** * This class parses WSDL files, and can be used by SOAP::Client to properly @@ -61,31 +60,55 @@ var $imports = array(); var $services = array(); var $service = ''; - var $uri = ''; - var $docs = false; /** - * Proxy parameters + * URL to WSDL file. + * + * @var string + */ + var $uri; + + /** + * Parse documentation in the WSDL? + * + * @var boolean + */ + var $docs; + + /** + * Proxy parameters. * * @var array */ - var $proxy = null; + var $proxy; - var $trace = 0; + /** + * Enable tracing in the generated proxy class? + * + * @var boolean + */ + var $trace = false; /** - * Use WSDL cache. + * Use WSDL cache? * * @var boolean */ - var $cacheUse = null; + var $cacheUse; + + /** + * WSDL cache directory. + * + * @var string + */ + var $cacheDir; /** - * Cache max lifetime (in seconds). + * Cache maximum lifetime (in seconds). * * @var integer */ - var $cacheMaxAge = null; + var $cacheMaxAge; /** * Class to use for WSDL parsing. Can be overridden for special cases, @@ -98,28 +121,31 @@ /** * SOAP_WSDL constructor. * - * @param string $wsdl_uri URL to WSDL file. - * @param array $proxy Contains options for HTTP_Request class - * @see HTTP_Request. - * @param boolean $cacheUse Use WSDL caching. Defaults to false. - * @param integer $cacheMaxAge Cache max lifetime (in seconds). - * @param boolean $docs Parse documentation in the WSDL? Defaults - * to false. + * @param string $wsdl_uri URL to WSDL file. + * @param array $proxy Options for HTTP_Request class + * @see HTTP_Request. + * @param boolean|string $cacheUse Use WSDL caching? The cache directory + * if a string. + * @param integer $cacheMaxAge Cache maximum lifetime (in seconds). + * @param boolean $docs Parse documentation in the WSDL? * * @access public */ function SOAP_WSDL($wsdl_uri = false, $proxy = array(), - $cacheUse = WSDL_CACHE_USE, + $cacheUse = false, $cacheMaxAge = WSDL_CACHE_MAX_AGE, $docs = false) { parent::SOAP_Base('WSDL'); $this->uri = $wsdl_uri; $this->proxy = $proxy; - $this->cacheUse = $cacheUse; + $this->cacheUse = !empty($cacheUse); $this->cacheMaxAge = $cacheMaxAge; $this->docs = $docs; + if (is_string($cacheUse)) { + $this->cacheDir = $cacheUse; + } if ($wsdl_uri) { if (!PEAR::isError($this->parseURL($wsdl_uri))) { @@ -682,7 +708,7 @@ " 'soapaction' => '$soapaction',\n" . " 'style' => '$opstyle',\n" . " 'use' => '$use'" . - ($this->trace?",\n 'trace' => 1" : '') . "));\n" . + ($this->trace ? ",\n 'trace' => 1" : '') . "));\n" . " return \$result;\n" . " }\n"; } @@ -877,45 +903,60 @@ class SOAP_WSDL_Cache extends SOAP_Base { - // Cache settings - /** - * Use WSDL cache + * Use WSDL cache? * * @var boolean */ - var $_cacheUse = null; + var $_cacheUse; /** - * Cache max lifetime (in seconds) + * WSDL cache directory. * - * @var int + * @var string */ - var $_cacheMaxAge = null; + var $_cacheDir; /** - * SOAP_WSDL_Cache constructor + * Cache maximum lifetime (in seconds) * - * @param boolean use caching - * @param int cache max lifetime (in seconds) - * @access public + * @var integer */ - function SOAP_WSDL_Cache($cacheUse = WSDL_CACHE_USE, - $cacheMaxAge = WSDL_CACHE_MAX_AGE) + var $_cacheMaxAge; + + /** + * Constructor. + * + * @param boolean $cashUse Use caching? + * @param integer $cacheMaxAge Cache maximum lifetime (in seconds) + */ + function SOAP_WSDL_Cache($cacheUse = false, + $cacheMaxAge = WSDL_CACHE_MAX_AGE, + $cacheDir = null) { parent::SOAP_Base('WSDLCACHE'); $this->_cacheUse = $cacheUse; + $this->_cacheDir = $cacheDir; $this->_cacheMaxAge = $cacheMaxAge; } /** - * _cacheDir - * return the path to the cache, if it doesn't exist, make it + * Returns the path to the cache and creates it, if it doesn't exist. + * + * @private + * + * @return string The directory to use for the cache. */ function _cacheDir() { - $dir = getenv("WSDLCACHE"); - if (!$dir) $dir = " ./wsdlcache"; + if (!empty($this->_cacheDir)) { + $dir = $this->_cacheDir; + } else { + $dir = getenv('WSDLCACHE'); + if (empty($dir)) { + $dir = './wsdlcache'; + } + } @mkdir($dir, 0700); return $dir; } @@ -935,7 +976,7 @@ $cachename = $md5_wsdl = $file_data = ''; if ($this->_cacheUse) { // Try to retrieve WSDL from cache - $cachename = SOAP_WSDL_Cache::_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; + $cachename = $this->_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; if (file_exists($cachename)) { $wf = fopen($cachename, 'rb'); if ($wf) { @@ -1054,12 +1095,14 @@ var $currentElement; /** - * constructor + * Constructor. */ function SOAP_WSDL_Parser($uri, &$wsdl, $docs = false) { parent::SOAP_Base('WSDLPARSER'); - $this->cache =& new SOAP_WSDL_Cache($wsdl->cacheUse, $wsdl->cacheMaxAge); + $this->cache =& new SOAP_WSDL_Cache($wsdl->cacheUse, + $wsdl->cacheMaxAge, + $wsdl->cacheDir); $this->uri = $uri; $this->wsdl = &$wsdl; $this->docs = $docs;
http://cvs.php.net/viewvc.cgi/pear/SOAP/package.xml?r1=1.83&r2=1.84&diff_format=u Index: pear/SOAP/package.xml diff -u pear/SOAP/package.xml:1.83 pear/SOAP/package.xml:1.84 --- pear/SOAP/package.xml:1.83 Mon Jun 19 16:35:10 2006 +++ pear/SOAP/package.xml Mon Jun 19 16:38:35 2006 @@ -43,7 +43,8 @@ <state>beta</state> <version>0.9.5</version> <date>2006-99-99</date> - <notes>* Replace all invalid characters in label and variable name of the generated proxy code. (Bug 7493). + <notes>* Allow to enable and disable WSDL caching and to set the cache directory in the client constructor. +* Replace all invalid characters in label and variable name of the generated proxy code. (Bug 7493). * Fix subsequent failures if one transmission with a Transport class instance failed (Bug 7469).</notes> <filelist> <dir name="/" baseinstalldir="SOAP"> http://cvs.php.net/viewvc.cgi/pear/SOAP/Client.php?r1=1.79&r2=1.80&diff_format=u Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.79 pear/SOAP/Client.php:1.80 --- pear/SOAP/Client.php:1.79 Thu Jun 1 11:03:20 2006 +++ pear/SOAP/Client.php Mon Jun 19 16:38:35 2006 @@ -190,14 +190,16 @@ * * @access public * - * @param string $endpoint An URL. - * @param boolean $wsdl Whether the endpoint is a WSDL file. - * @param string $portName - * @param array $proxy_params Options for the HTTP_Request class (see - * HTTP/Request.php) + * @param string $endpoint An URL. + * @param boolean $wsdl Whether the endpoint is a WSDL file. + * @param string $portName The service's port name to use. + * @param array $proxy_params Options for the HTTP_Request class + * @see HTTP_Request + * @param boolean|string $cache Use WSDL caching? The cache directory if + * a string. */ function SOAP_Client($endpoint, $wsdl = false, $portName = false, - $proxy_params = array()) + $proxy_params = array(), $cache = false) { parent::SOAP_Base('Client'); @@ -216,7 +218,8 @@ $this->__endpointType = 'wsdl'; // instantiate wsdl class $this->_wsdl =& new SOAP_WSDL($this->_endpoint, - $this->__proxy_params); + $this->__proxy_params, + $cache); if ($this->_wsdl->fault) { $this->_raiseSoapFault($this->_wsdl->fault); } @@ -346,8 +349,8 @@ // Save the wire information for debugging. if ($this->__options['trace'] > 0) { - $this->__last_request =& $this->_soap_transport->outgoing_payload; - $this->__last_response =& $this->_soap_transport->incoming_payload; + $this->__last_request = $this->_soap_transport->outgoing_payload; + $this->__last_response = $this->_soap_transport->incoming_payload; $this->wire = $this->__get_wire(); } if ($this->_soap_transport->fault) { http://cvs.php.net/viewvc.cgi/pear/SOAP/WSDL.php?r1=1.89&r2=1.90&diff_format=u Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.89 pear/SOAP/WSDL.php:1.90 --- pear/SOAP/WSDL.php:1.89 Mon Jun 19 15:20:39 2006 +++ pear/SOAP/WSDL.php Mon Jun 19 16:38:35 2006 @@ -27,7 +27,6 @@ require_once 'HTTP/Request.php'; define('WSDL_CACHE_MAX_AGE', 43200); -define('WSDL_CACHE_USE', 0); // set to zero to turn off caching /** * This class parses WSDL files, and can be used by SOAP::Client to properly @@ -61,31 +60,55 @@ var $imports = array(); var $services = array(); var $service = ''; - var $uri = ''; - var $docs = false; /** - * Proxy parameters + * URL to WSDL file. + * + * @var string + */ + var $uri; + + /** + * Parse documentation in the WSDL? + * + * @var boolean + */ + var $docs; + + /** + * Proxy parameters. * * @var array */ - var $proxy = null; + var $proxy; - var $trace = 0; + /** + * Enable tracing in the generated proxy class? + * + * @var boolean + */ + var $trace = false; /** - * Use WSDL cache. + * Use WSDL cache? * * @var boolean */ - var $cacheUse = null; + var $cacheUse; + + /** + * WSDL cache directory. + * + * @var string + */ + var $cacheDir; /** - * Cache max lifetime (in seconds). + * Cache maximum lifetime (in seconds). * * @var integer */ - var $cacheMaxAge = null; + var $cacheMaxAge; /** * Class to use for WSDL parsing. Can be overridden for special cases, @@ -98,28 +121,31 @@ /** * SOAP_WSDL constructor. * - * @param string $wsdl_uri URL to WSDL file. - * @param array $proxy Contains options for HTTP_Request class - * @see HTTP_Request. - * @param boolean $cacheUse Use WSDL caching. Defaults to false. - * @param integer $cacheMaxAge Cache max lifetime (in seconds). - * @param boolean $docs Parse documentation in the WSDL? Defaults - * to false. + * @param string $wsdl_uri URL to WSDL file. + * @param array $proxy Options for HTTP_Request class + * @see HTTP_Request. + * @param boolean|string $cacheUse Use WSDL caching? The cache directory + * if a string. + * @param integer $cacheMaxAge Cache maximum lifetime (in seconds). + * @param boolean $docs Parse documentation in the WSDL? * * @access public */ function SOAP_WSDL($wsdl_uri = false, $proxy = array(), - $cacheUse = WSDL_CACHE_USE, + $cacheUse = false, $cacheMaxAge = WSDL_CACHE_MAX_AGE, $docs = false) { parent::SOAP_Base('WSDL'); $this->uri = $wsdl_uri; $this->proxy = $proxy; - $this->cacheUse = $cacheUse; + $this->cacheUse = !empty($cacheUse); $this->cacheMaxAge = $cacheMaxAge; $this->docs = $docs; + if (is_string($cacheUse)) { + $this->cacheDir = $cacheUse; + } if ($wsdl_uri) { if (!PEAR::isError($this->parseURL($wsdl_uri))) { @@ -682,7 +708,7 @@ " 'soapaction' => '$soapaction',\n" . " 'style' => '$opstyle',\n" . " 'use' => '$use'" . - ($this->trace?",\n 'trace' => 1" : '') . "));\n" . + ($this->trace ? ",\n 'trace' => 1" : '') . "));\n" . " return \$result;\n" . " }\n"; } @@ -877,45 +903,60 @@ class SOAP_WSDL_Cache extends SOAP_Base { - // Cache settings - /** - * Use WSDL cache + * Use WSDL cache? * * @var boolean */ - var $_cacheUse = null; + var $_cacheUse; /** - * Cache max lifetime (in seconds) + * WSDL cache directory. * - * @var int + * @var string */ - var $_cacheMaxAge = null; + var $_cacheDir; /** - * SOAP_WSDL_Cache constructor + * Cache maximum lifetime (in seconds) * - * @param boolean use caching - * @param int cache max lifetime (in seconds) - * @access public + * @var integer */ - function SOAP_WSDL_Cache($cacheUse = WSDL_CACHE_USE, - $cacheMaxAge = WSDL_CACHE_MAX_AGE) + var $_cacheMaxAge; + + /** + * Constructor. + * + * @param boolean $cashUse Use caching? + * @param integer $cacheMaxAge Cache maximum lifetime (in seconds) + */ + function SOAP_WSDL_Cache($cacheUse = false, + $cacheMaxAge = WSDL_CACHE_MAX_AGE, + $cacheDir = null) { parent::SOAP_Base('WSDLCACHE'); $this->_cacheUse = $cacheUse; + $this->_cacheDir = $cacheDir; $this->_cacheMaxAge = $cacheMaxAge; } /** - * _cacheDir - * return the path to the cache, if it doesn't exist, make it + * Returns the path to the cache and creates it, if it doesn't exist. + * + * @private + * + * @return string The directory to use for the cache. */ function _cacheDir() { - $dir = getenv("WSDLCACHE"); - if (!$dir) $dir = " ./wsdlcache"; + if (!empty($this->_cacheDir)) { + $dir = $this->_cacheDir; + } else { + $dir = getenv('WSDLCACHE'); + if (empty($dir)) { + $dir = './wsdlcache'; + } + } @mkdir($dir, 0700); return $dir; } @@ -935,7 +976,7 @@ $cachename = $md5_wsdl = $file_data = ''; if ($this->_cacheUse) { // Try to retrieve WSDL from cache - $cachename = SOAP_WSDL_Cache::_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; + $cachename = $this->_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; if (file_exists($cachename)) { $wf = fopen($cachename, 'rb'); if ($wf) { @@ -1054,12 +1095,14 @@ var $currentElement; /** - * constructor + * Constructor. */ function SOAP_WSDL_Parser($uri, &$wsdl, $docs = false) { parent::SOAP_Base('WSDLPARSER'); - $this->cache =& new SOAP_WSDL_Cache($wsdl->cacheUse, $wsdl->cacheMaxAge); + $this->cache =& new SOAP_WSDL_Cache($wsdl->cacheUse, + $wsdl->cacheMaxAge, + $wsdl->cacheDir); $this->uri = $uri; $this->wsdl = &$wsdl; $this->docs = $docs;