diff options
Diffstat (limited to 'library/vendor/Zend/Soap')
19 files changed, 4699 insertions, 0 deletions
diff --git a/library/vendor/Zend/Soap/AutoDiscover.php b/library/vendor/Zend/Soap/AutoDiscover.php new file mode 100644 index 0000000..794d2a1 --- /dev/null +++ b/library/vendor/Zend/Soap/AutoDiscover.php @@ -0,0 +1,597 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage AutoDiscover + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Server_Interface + */ +/** + * @see Zend_Soap_Wsdl + */ +/** + * @see Zend_Server_Reflection + */ +/** + * @see Zend_Server_Abstract + */ +/** + * @see Zend_Uri + */ + +/** + * Zend_Soap_AutoDiscover + * + * @category Zend + * @package Zend_Soap + * @subpackage AutoDiscover + */ +class Zend_Soap_AutoDiscover implements Zend_Server_Interface +{ + /** + * @var Zend_Soap_Wsdl + */ + protected $_wsdl = null; + + /** + * @var Zend_Server_Reflection + */ + protected $_reflection = null; + + /** + * @var array + */ + protected $_functions = array(); + + /** + * @var boolean + */ + protected $_strategy; + + /** + * Url where the WSDL file will be available at. + * + * @var WSDL Uri + */ + protected $_uri; + + /** + * soap:body operation style options + * + * @var array + */ + protected $_operationBodyStyle = array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"); + + /** + * soap:operation style + * + * @var array + */ + protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http'); + + /** + * Name of the class to handle the WSDL creation. + * + * @var string + */ + protected $_wsdlClass = 'Zend_Soap_Wsdl'; + + /** + * Constructor + * + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @param string|Zend_Uri $uri + * @param string $wsdlClass + */ + public function __construct($strategy = true, $uri=null, $wsdlClass=null) + { + $this->_reflection = new Zend_Server_Reflection(); + $this->setComplexTypeStrategy($strategy); + + if($uri !== null) { + $this->setUri($uri); + } + + if($wsdlClass !== null) { + $this->setWsdlClass($wsdlClass); + } + } + + /** + * Set the location at which the WSDL file will be availabe. + * + * @see Zend_Soap_Exception + * @param Zend_Uri|string $uri + * @return Zend_Soap_AutoDiscover + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function setUri($uri) + { + if (!is_string($uri) && !($uri instanceof Zend_Uri)) { + throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance."); + } + $this->_uri = $uri; + + // change uri in WSDL file also if existant + if ($this->_wsdl instanceof Zend_Soap_Wsdl) { + $this->_wsdl->setUri($uri); + } + + return $this; + } + + /** + * Return the current Uri that the SOAP WSDL Service will be located at. + * + * @return Zend_Uri + */ + public function getUri() + { + if($this->_uri !== null) { + $uri = $this->_uri; + } else { + $schema = $this->getSchema(); + $host = $this->getHostName(); + $scriptName = $this->getRequestUriWithoutParameters(); + $uri = Zend_Uri::factory($schema . '://' . $host . $scriptName); + $this->setUri($uri); + } + return $uri; + } + + /** + * Set the name of the WSDL handling class. + * + * @see Zend_Soap_Exception + * @see Zend_Soap_Exception + * @param string $wsdlClass + * @return Zend_Soap_AutoDiscover + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function setWsdlClass($wsdlClass) + { + if (!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) { + throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string."); + } + $this->_wsdlClass = $wsdlClass; + + return $this; + } + + /** + * Return the name of the WSDL handling class. + * + * @return string + */ + public function getWsdlClass() + { + return $this->_wsdlClass; + } + + /** + * Set options for all the binding operations soap:body elements. + * + * By default the options are set to 'use' => 'encoded' and + * 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/". + * + * @see Zend_Soap_AutoDiscover_Exception + * @param array $operationStyle + * @return Zend_Soap_AutoDiscover + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function setOperationBodyStyle(array $operationStyle=array()) + { + if(!isset($operationStyle['use'])) { + throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style."); + } + $this->_operationBodyStyle = $operationStyle; + return $this; + } + + /** + * Set Binding soap:binding style. + * + * By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'. + * + * @param array $bindingStyle + * @return Zend_Soap_AutoDiscover + */ + public function setBindingStyle(array $bindingStyle=array()) + { + if(isset($bindingStyle['style'])) { + $this->_bindingStyle['style'] = $bindingStyle['style']; + } + if(isset($bindingStyle['transport'])) { + $this->_bindingStyle['transport'] = $bindingStyle['transport']; + } + return $this; + } + + /** + * Detect and returns the current HTTP/HTTPS Schema + * + * @return string + */ + protected function getSchema() + { + $schema = "http"; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { + $schema = 'https'; + } + return $schema; + } + + /** + * Detect and return the current hostname + * + * @return string + */ + protected function getHostName() + { + if(isset($_SERVER['HTTP_HOST'])) { + $host = $_SERVER['HTTP_HOST']; + } else { + $host = $_SERVER['SERVER_NAME']; + } + return $host; + } + + /** + * Detect and return the current script name without parameters + * + * @return string + */ + protected function getRequestUriWithoutParameters() + { + if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { // IIS with Microsoft Rewrite Module + $requestUri = $_SERVER['HTTP_X_ORIGINAL_URL']; + } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch + $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; + } elseif (isset($_SERVER['REQUEST_URI'])) { + $requestUri = $_SERVER['REQUEST_URI']; + } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI + $requestUri = $_SERVER['ORIG_PATH_INFO']; + } else { + $requestUri = $_SERVER['SCRIPT_NAME']; + } + if( ($pos = strpos($requestUri, "?")) !== false) { + $requestUri = substr($requestUri, 0, $pos); + } + + return $requestUri; + } + + /** + * Set the strategy that handles functions and classes that are added AFTER this call. + * + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_AutoDiscover + */ + public function setComplexTypeStrategy($strategy) + { + $this->_strategy = $strategy; + if($this->_wsdl instanceof Zend_Soap_Wsdl) { + $this->_wsdl->setComplexTypeStrategy($strategy); + } + + return $this; + } + + /** + * Set the Class the SOAP server will use + * + * @param string $class Class Name + * @param string $namespace Class Namspace - Not Used + * @param array $argv Arguments to instantiate the class - Not Used + * @return Zend_Soap_AutoDiscover + */ + public function setClass($class, $namespace = '', $argv = null) + { + $uri = $this->getUri(); + + $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy); + + // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) + $wsdl->addSchemaTypeSection(); + + $port = $wsdl->addPortType($class . 'Port'); + $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port'); + + $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); + $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); + foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); + } + $this->_wsdl = $wsdl; + + return $this; + } + + /** + * Add a Single or Multiple Functions to the WSDL + * + * @param string $function Function Name + * @param string $namespace Function namespace - Not Used + * @return Zend_Soap_AutoDiscover + */ + public function addFunction($function, $namespace = '') + { + static $port; + static $operation; + static $binding; + + if (!is_array($function)) { + $function = (array) $function; + } + + $uri = $this->getUri(); + + if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy); + + // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) + $wsdl->addSchemaTypeSection(); + + $port = $wsdl->addPortType($name . 'Port'); + $binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port'); + + $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); + $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri); + } else { + $wsdl = $this->_wsdl; + } + + foreach ($function as $func) { + $method = $this->_reflection->reflectFunction($func); + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); + } + $this->_wsdl = $wsdl; + + return $this; + } + + /** + * Add a function to the WSDL document. + * + * @param Zend_Server_Reflection_Function_Abstract $function function to add + * @param Zend_Soap_Wsdl $wsdl WSDL document + * @param object $port wsdl:portType + * @param object $binding wsdl:binding + * @return void + */ + protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) + { + $uri = $this->getUri(); + + // We only support one prototype: the one with the maximum number of arguments + $prototype = null; + $maxNumArgumentsOfPrototype = -1; + foreach ($function->getPrototypes() as $tmpPrototype) { + $numParams = count($tmpPrototype->getParameters()); + if ($numParams > $maxNumArgumentsOfPrototype) { + $maxNumArgumentsOfPrototype = $numParams; + $prototype = $tmpPrototype; + } + } + if ($prototype === null) { + throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function"); + } + + // Add the input message (parameters) + $args = array(); + if ($this->_bindingStyle['style'] == 'document') { + // Document style: wrap all parameters in a sequence element + $sequence = array(); + foreach ($prototype->getParameters() as $param) { + $sequenceElement = array( + 'name' => $param->getName(), + 'type' => $wsdl->getType($param->getType()) + ); + if ($param->isOptional()) { + $sequenceElement['nillable'] = 'true'; + } + $sequence[] = $sequenceElement; + } + $element = array( + 'name' => $function->getName(), + 'sequence' => $sequence + ); + // Add the wrapper element part, which must be named 'parameters' + $args['parameters'] = array('element' => $wsdl->addElement($element)); + } else { + // RPC style: add each parameter as a typed part + foreach ($prototype->getParameters() as $param) { + $args[$param->getName()] = array('type' => $wsdl->getType($param->getType())); + } + } + $wsdl->addMessage($function->getName() . 'In', $args); + + $isOneWayMessage = false; + if($prototype->getReturnType() == "void") { + $isOneWayMessage = true; + } + + if($isOneWayMessage == false) { + // Add the output message (return value) + $args = array(); + if ($this->_bindingStyle['style'] == 'document') { + // Document style: wrap the return value in a sequence element + $sequence = array(); + if ($prototype->getReturnType() != "void") { + $sequence[] = array( + 'name' => $function->getName() . 'Result', + 'type' => $wsdl->getType($prototype->getReturnType()) + ); + } + $element = array( + 'name' => $function->getName() . 'Response', + 'sequence' => $sequence + ); + // Add the wrapper element part, which must be named 'parameters' + $args['parameters'] = array('element' => $wsdl->addElement($element)); + } else if ($prototype->getReturnType() != "void") { + // RPC style: add the return value as a typed part + $args['return'] = array('type' => $wsdl->getType($prototype->getReturnType())); + } + $wsdl->addMessage($function->getName() . 'Out', $args); + } + + // Add the portType operation + if($isOneWayMessage == false) { + $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', 'tns:' . $function->getName() . 'Out'); + } else { + $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', false); + } + $desc = $function->getDescription(); + if (strlen($desc) > 0) { + $wsdl->addDocumentation($portOperation, $desc); + } + + // When using the RPC style, make sure the operation style includes a 'namespace' attribute (WS-I Basic Profile 1.1 R2717) + if ($this->_bindingStyle['style'] == 'rpc' && !isset($this->_operationBodyStyle['namespace'])) { + $this->_operationBodyStyle['namespace'] = ''.$uri; + } + + // Add the binding operation + if($isOneWayMessage == false) { + $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); + } else { + $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle); + } + $wsdl->addSoapOperation($operation, $uri . '#' .$function->getName()); + + // Add the function name to the list + $this->_functions[] = $function->getName(); + } + + /** + * Action to take when an error occurs + * + * @param string $fault + * @param string|int $code + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function fault($fault = null, $code = null) + { + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Handle the Request + * + * @param string $request A non-standard request - Not Used + */ + public function handle($request = false) + { + if (!headers_sent()) { + header('Content-Type: text/xml'); + } + $this->_wsdl->dump(); + } + + /** + * Proxy to WSDL dump function + * + * @param string $filename + * @return boolean + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function dump($filename) + { + if($this->_wsdl !== null) { + return $this->_wsdl->dump($filename); + } else { + /** + * @see Zend_Soap_AutoDiscover_Exception + */ + throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet."); + } + } + + /** + * Proxy to WSDL toXml() function + * + * @return string + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function toXml() + { + if($this->_wsdl !== null) { + return $this->_wsdl->toXml(); + } else { + /** + * @see Zend_Soap_AutoDiscover_Exception + */ + throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet."); + } + } + + /** + * Return an array of functions in the WSDL + * + * @return array + */ + public function getFunctions() + { + return $this->_functions; + } + + /** + * Load Functions + * + * @param unknown_type $definition + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function loadFunctions($definition) + { + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Set Persistance + * + * @param int $mode + * @throws Zend_Soap_AutoDiscover_Exception + */ + public function setPersistence($mode) + { + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Returns an XSD Type for the given PHP type + * + * @param string $type PHP Type to get the XSD type for + * @return string + */ + public function getType($type) + { + if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + /** @todo Exception throwing may be more correct */ + + // WSDL is not defined yet, so we can't recognize type in context of current service + return ''; + } else { + return $this->_wsdl->getType($type); + } + } +} diff --git a/library/vendor/Zend/Soap/AutoDiscover/Exception.php b/library/vendor/Zend/Soap/AutoDiscover/Exception.php new file mode 100644 index 0000000..6b6491e --- /dev/null +++ b/library/vendor/Zend/Soap/AutoDiscover/Exception.php @@ -0,0 +1,33 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage AutoDiscover + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Exception + */ + +/** + * @package Zend_Soap + * @subpackage AutoDiscover + */ +class Zend_Soap_AutoDiscover_Exception extends Zend_Exception +{ +} diff --git a/library/vendor/Zend/Soap/Client.php b/library/vendor/Zend/Soap/Client.php new file mode 100644 index 0000000..e58223f --- /dev/null +++ b/library/vendor/Zend/Soap/Client.php @@ -0,0 +1,1223 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Server + */ + +/** + * @see Zend_Soap_Client_Local + */ + +/** + * @see Zend_Soap_Client_Common + */ + +/** + * Zend_Soap_Client + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Client +{ + /** + * Encoding + * @var string + */ + protected $_encoding = 'UTF-8'; + + /** + * Array of SOAP type => PHP class pairings for handling return/incoming values + * @var array + */ + protected $_classmap = null; + + /** + * Registered fault exceptions + * @var array + */ + protected $_faultExceptions = array(); + + /** + * SOAP version to use; SOAP_1_2 by default, to allow processing of headers + * @var int + */ + protected $_soapVersion = SOAP_1_2; + + /** Set of other SoapClient options */ + protected $_uri = null; + protected $_location = null; + protected $_style = null; + protected $_use = null; + protected $_login = null; + protected $_password = null; + protected $_proxy_host = null; + protected $_proxy_port = null; + protected $_proxy_login = null; + protected $_proxy_password = null; + protected $_local_cert = null; + protected $_passphrase = null; + protected $_compression = null; + protected $_connection_timeout = null; + protected $_stream_context = null; + protected $_features = null; + protected $_cache_wsdl = null; + protected $_user_agent = null; + protected $_exceptions = null; + + /** + * WSDL used to access server + * It also defines Zend_Soap_Client working mode (WSDL vs non-WSDL) + * + * @var string + */ + protected $_wsdl = null; + + /** + * SoapClient object + * + * @var SoapClient + */ + protected $_soapClient; + + /** + * Last invoked method + * + * @var string + */ + protected $_lastMethod = ''; + + /** + * SOAP request headers. + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_soapInputHeaders = array(); + + /** + * Permanent SOAP request headers (shared between requests). + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_permanentSoapInputHeaders = array(); + + /** + * Output SOAP headers. + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_soapOutputHeaders = array(); + + /** + * Constructor + * + * @param string $wsdl + * @param array $options + */ + public function __construct($wsdl = null, $options = null) + { + if (!extension_loaded('soap')) { + throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.'); + } + + if ($wsdl !== null) { + $this->setWsdl($wsdl); + } + if ($options !== null) { + $this->setOptions($options); + } + } + + /** + * Set wsdl + * + * @param string $wsdl + * @return Zend_Soap_Client + */ + public function setWsdl($wsdl) + { + $this->_wsdl = $wsdl; + $this->_soapClient = null; + + return $this; + } + + /** + * Get wsdl + * + * @return string + */ + public function getWsdl() + { + return $this->_wsdl; + } + + /** + * Set Options + * + * Allows setting options as an associative array of option => value pairs. + * + * @param array|Zend_Config $options + * @return Zend_Soap_Client + * @throws Zend_SoapClient_Exception + */ + public function setOptions($options) + { + if($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + foreach ($options as $key => $value) { + switch ($key) { + case 'classmap': + case 'classMap': + $this->setClassmap($value); + break; + case 'encoding': + $this->setEncoding($value); + break; + case 'soapVersion': + case 'soap_version': + $this->setSoapVersion($value); + break; + case 'wsdl': + $this->setWsdl($value); + break; + case 'uri': + $this->setUri($value); + break; + case 'location': + $this->setLocation($value); + break; + case 'style': + $this->setStyle($value); + break; + case 'use': + $this->setEncodingMethod($value); + break; + case 'login': + $this->setHttpLogin($value); + break; + case 'password': + $this->setHttpPassword($value); + break; + case 'proxy_host': + $this->setProxyHost($value); + break; + case 'proxy_port': + $this->setProxyPort($value); + break; + case 'proxy_login': + $this->setProxyLogin($value); + break; + case 'proxy_password': + $this->setProxyPassword($value); + break; + case 'local_cert': + $this->setHttpsCertificate($value); + break; + case 'passphrase': + $this->setHttpsCertPassphrase($value); + break; + case 'compression': + $this->setCompressionOptions($value); + break; + case 'stream_context': + $this->setStreamContext($value); + break; + case 'features': + $this->setSoapFeatures($value); + break; + case 'cache_wsdl': + $this->setWsdlCache($value); + break; + case 'useragent': + case 'userAgent': + case 'user_agent': + $this->setUserAgent($value); + break; + case 'exceptions': + $this->setExceptions($value); + break; + + // Not used now + // case 'connection_timeout': + // $this->_connection_timeout = $value; + // break; + + default: + throw new Zend_Soap_Client_Exception('Unknown SOAP client option'); + break; + } + } + + return $this; + } + + /** + * Return array of options suitable for using with SoapClient constructor + * + * @return array + */ + public function getOptions() + { + $options = array(); + + $options['classmap'] = $this->getClassmap(); + $options['encoding'] = $this->getEncoding(); + $options['soap_version'] = $this->getSoapVersion(); + $options['wsdl'] = $this->getWsdl(); + $options['uri'] = $this->getUri(); + $options['location'] = $this->getLocation(); + $options['style'] = $this->getStyle(); + $options['use'] = $this->getEncodingMethod(); + $options['login'] = $this->getHttpLogin(); + $options['password'] = $this->getHttpPassword(); + $options['proxy_host'] = $this->getProxyHost(); + $options['proxy_port'] = $this->getProxyPort(); + $options['proxy_login'] = $this->getProxyLogin(); + $options['proxy_password'] = $this->getProxyPassword(); + $options['local_cert'] = $this->getHttpsCertificate(); + $options['passphrase'] = $this->getHttpsCertPassphrase(); + $options['compression'] = $this->getCompressionOptions(); + //$options['connection_timeout'] = $this->_connection_timeout; + $options['stream_context'] = $this->getStreamContext(); + $options['cache_wsdl'] = $this->getWsdlCache(); + $options['features'] = $this->getSoapFeatures(); + $options['user_agent'] = $this->getUserAgent(); + $options['exceptions'] = $this->getExceptions(); + + foreach ($options as $key => $value) { + /* + * ugly hack as I don't know if checking for '=== null' + * breaks some other option + */ + if (in_array($key, array('user_agent', 'cache_wsdl', 'compression', 'exceptions'))) { + if ($value === null) { + unset($options[$key]); + } + } else { + if ($value == null) { + unset($options[$key]); + } + } + } + + return $options; + } + + /** + * Set SOAP version + * + * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid soap version argument + */ + public function setSoapVersion($version) + { + if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { + throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); + } + $this->_soapVersion = $version; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get SOAP version + * + * @return int + */ + public function getSoapVersion() + { + return $this->_soapVersion; + } + + /** + * Set classmap + * + * @param array $classmap + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception for any invalid class in the class map + */ + public function setClassmap(array $classmap) + { + foreach ($classmap as $type => $class) { + if (!class_exists($class)) { + throw new Zend_Soap_Client_Exception('Invalid class in class map'); + } + } + + $this->_classmap = $classmap; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve classmap + * + * @return mixed + */ + public function getClassmap() + { + return $this->_classmap; + } + + /** + * Set encoding + * + * @param string $encoding + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid encoding argument + */ + public function setEncoding($encoding) + { + if (!is_string($encoding)) { + throw new Zend_Soap_Client_Exception('Invalid encoding specified'); + } + + $this->_encoding = $encoding; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get encoding + * + * @return string + */ + public function getEncoding() + { + return $this->_encoding; + } + + /** + * Check for valid URN + * + * @param string $urn + * @return true + * @throws Zend_Soap_Client_Exception on invalid URN + */ + public function validateUrn($urn) + { + $scheme = parse_url($urn, PHP_URL_SCHEME); + if ($scheme === false || $scheme === null) { + throw new Zend_Soap_Client_Exception('Invalid URN'); + } + + return true; + + } + + /** + * Set URI + * + * URI in Web Service the target namespace + * + * @param string $uri + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid uri argument + */ + public function setUri($uri) + { + $this->validateUrn($uri); + $this->_uri = $uri; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getUri() + { + return $this->_uri; + } + + /** + * Set Location + * + * URI in Web Service the target namespace + * + * @param string $location + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid uri argument + */ + public function setLocation($location) + { + $this->validateUrn($location); + $this->_location = $location; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getLocation() + { + return $this->_location; + } + + /** + * Set request style + * + * @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid style argument + */ + public function setStyle($style) + { + if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { + throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); + } + + $this->_style = $style; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get request style + * + * @return int + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Set message encoding method + * + * @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid message encoding method argument + */ + public function setEncodingMethod($use) + { + if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { + throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); + } + + $this->_use = $use; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get message encoding method + * + * @return int + */ + public function getEncodingMethod() + { + return $this->_use; + } + + /** + * Set HTTP login + * + * @param string $login + * @return Zend_Soap_Client + */ + public function setHttpLogin($login) + { + $this->_login = $login; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve HTTP Login + * + * @return string + */ + public function getHttpLogin() + { + return $this->_login; + } + + /** + * Set HTTP password + * + * @param string $password + * @return Zend_Soap_Client + */ + public function setHttpPassword($password) + { + $this->_password = $password; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve HTTP Password + * + * @return string + */ + public function getHttpPassword() + { + return $this->_password; + } + + /** + * Set proxy host + * + * @param string $proxyHost + * @return Zend_Soap_Client + */ + public function setProxyHost($proxyHost) + { + $this->_proxy_host = $proxyHost; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy host + * + * @return string + */ + public function getProxyHost() + { + return $this->_proxy_host; + } + + /** + * Set proxy port + * + * @param int $proxyPort + * @return Zend_Soap_Client + */ + public function setProxyPort($proxyPort) + { + $this->_proxy_port = (int)$proxyPort; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy port + * + * @return int + */ + public function getProxyPort() + { + return $this->_proxy_port; + } + + /** + * Set proxy login + * + * @param string $proxyLogin + * @return Zend_Soap_Client + */ + public function setProxyLogin($proxyLogin) + { + $this->_proxy_login = $proxyLogin; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy login + * + * @return string + */ + public function getProxyLogin() + { + return $this->_proxy_login; + } + + /** + * Set proxy password + * + * @param string $proxyLogin + * @return Zend_Soap_Client + */ + public function setProxyPassword($proxyPassword) + { + $this->_proxy_password = $proxyPassword; + + $this->_soapClient = null; + + return $this; + } + + /** + * Set HTTPS client certificate path + * + * @param string $localCert local certificate path + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid local certificate path argument + */ + public function setHttpsCertificate($localCert) + { + if (!is_readable($localCert)) { + throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.'); + } + + $this->_local_cert = $localCert; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get HTTPS client certificate path + * + * @return string + */ + public function getHttpsCertificate() + { + return $this->_local_cert; + } + + /** + * Set HTTPS client certificate passphrase + * + * @param string $passphrase + * @return Zend_Soap_Client + */ + public function setHttpsCertPassphrase($passphrase) + { + $this->_passphrase = $passphrase; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get HTTPS client certificate passphrase + * + * @return string + */ + public function getHttpsCertPassphrase() + { + return $this->_passphrase; + } + + /** + * Set compression options + * + * @param int|null $compressionOptions + * @return Zend_Soap_Client + */ + public function setCompressionOptions($compressionOptions) + { + if ($compressionOptions === null) { + $this->_compression = null; + } else { + $this->_compression = (int)$compressionOptions; + } + $this->_soapClient = null; + return $this; + } + + /** + * Get Compression options + * + * @return int + */ + public function getCompressionOptions() + { + return $this->_compression; + } + + /** + * Retrieve proxy password + * + * @return string + */ + public function getProxyPassword() + { + return $this->_proxy_password; + } + + /** + * Set Stream Context + * + * @return Zend_Soap_Client + */ + public function setStreamContext($context) + { + if(!is_resource($context) || get_resource_type($context) !== "stream-context") { + /** + * @see Zend_Soap_Client_Exception + */ + throw new Zend_Soap_Client_Exception( + "Invalid stream context resource given." + ); + } + + $this->_stream_context = $context; + return $this; + } + + /** + * Get Stream Context + * + * @return resource + */ + public function getStreamContext() + { + return $this->_stream_context; + } + + /** + * Set the SOAP Feature options. + * + * @param string|int $feature + * @return Zend_Soap_Client + */ + public function setSoapFeatures($feature) + { + $this->_features = $feature; + + $this->_soapClient = null; + return $this; + } + + /** + * Return current SOAP Features options + * + * @return int + */ + public function getSoapFeatures() + { + return $this->_features; + } + + /** + * Set the SOAP Wsdl Caching Options + * + * @param string|int|boolean|null $caching + * @return Zend_Soap_Client + */ + public function setWsdlCache($caching) + { + if ($caching === null) { + $this->_cache_wsdl = null; + } else { + $this->_cache_wsdl = (int)$caching; + } + return $this; + } + + /** + * Get current SOAP Wsdl Caching option + * + * @return int + */ + public function getWsdlCache() + { + return $this->_cache_wsdl; + } + + /** + * Set the string to use in User-Agent header + * + * @param string|null $userAgent + * @return Zend_Soap_Client + */ + public function setUserAgent($userAgent) + { + if ($userAgent === null) { + $this->_user_agent = null; + } else { + $this->_user_agent = (string)$userAgent; + } + return $this; + } + + /** + * Get current string to use in User-Agent header + * + * @return string|null + */ + public function getUserAgent() + { + return $this->_user_agent; + } + + /** + * Set the exceptions option + * + * The exceptions option is a boolean value defining whether soap errors + * throw exceptions. + * + * @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters + * + * @param bool $exceptions + * @return $this + */ + public function setExceptions($exceptions) + { + $this->_exceptions = (bool) $exceptions; + + return $this; + } + + /** + * Get the exceptions option + * + * The exceptions option is a boolean value defining whether soap errors + * throw exceptions. + * + * @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters + * + * @return bool|null + */ + public function getExceptions() + { + return $this->_exceptions; + } + + /** + * Retrieve request XML + * + * @return string + */ + public function getLastRequest() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastRequest(); + } + + return ''; + } + + /** + * Get response XML + * + * @return string + */ + public function getLastResponse() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastResponse(); + } + + return ''; + } + + /** + * Retrieve request headers + * + * @return string + */ + public function getLastRequestHeaders() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastRequestHeaders(); + } + + return ''; + } + + /** + * Retrieve response headers (as string) + * + * @return string + */ + public function getLastResponseHeaders() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastResponseHeaders(); + } + + return ''; + } + + /** + * Retrieve last invoked method + * + * @return string + */ + public function getLastMethod() + { + return $this->_lastMethod; + } + + /** + * Do request proxy method. + * + * May be overridden in subclasses + * + * @internal + * @param Zend_Soap_Client_Common $client + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + { + // Perform request as is + if ($one_way == null) { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); + } else { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); + } + } + + /** + * Initialize SOAP Client object + * + * @throws Zend_Soap_Client_Exception + */ + protected function _initSoapClientObject() + { + $wsdl = $this->getWsdl(); + $options = array_merge($this->getOptions(), array('trace' => true)); + + if ($wsdl == null) { + if (!isset($options['location'])) { + throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); + } + if (!isset($options['uri'])) { + throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); + } + } else { + if (isset($options['use'])) { + throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); + } + if (isset($options['style'])) { + throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); + } + } + unset($options['wsdl']); + + $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options); + } + + + /** + * Perform arguments pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessArguments($arguments) + { + // Do nothing + return $arguments; + } + + /** + * Perform result pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessResult($result) + { + // Do nothing + return $result; + } + + /** + * Add SOAP input header + * + * @param SoapHeader $header + * @param boolean $permanent + * @return Zend_Soap_Client + */ + public function addSoapInputHeader(SoapHeader $header, $permanent = false) + { + if ($permanent) { + $this->_permanentSoapInputHeaders[] = $header; + } else { + $this->_soapInputHeaders[] = $header; + } + + return $this; + } + + /** + * Reset SOAP input headers + * + * @return Zend_Soap_Client + */ + public function resetSoapInputHeaders() + { + $this->_permanentSoapInputHeaders = array(); + $this->_soapInputHeaders = array(); + + return $this; + } + + /** + * Get last SOAP output headers + * + * @return array + */ + public function getLastSoapOutputHeaderObjects() + { + return $this->_soapOutputHeaders; + } + + /** + * Perform a SOAP call + * + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + $soapClient = $this->getSoapClient(); + + $this->_lastMethod = $name; + + $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); + $result = $soapClient->__soapCall($name, + $this->_preProcessArguments($arguments), + null, /* Options are already set to the SOAP client object */ + (count($soapHeaders) > 0)? $soapHeaders : null, + $this->_soapOutputHeaders); + + // Reset non-permanent input headers + $this->_soapInputHeaders = array(); + + return $this->_preProcessResult($result); + } + + + /** + * Return a list of available functions + * + * @return array + * @throws Zend_Soap_Client_Exception + */ + public function getFunctions() + { + if ($this->getWsdl() == null) { + throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); + } + + $soapClient = $this->getSoapClient(); + return $soapClient->__getFunctions(); + } + + + /** + * Get used types. + * + * @return array + */ + + /** + * Return a list of SOAP types + * + * @return array + * @throws Zend_Soap_Client_Exception + */ + public function getTypes() + { + if ($this->getWsdl() == null) { + throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); + } + + $soapClient = $this->getSoapClient(); + + return $soapClient->__getTypes(); + } + + /** + * @param SoapClient $soapClient + * @return Zend_Soap_Client + */ + public function setSoapClient(SoapClient $soapClient) + { + $this->_soapClient = $soapClient; + return $this; + } + + /** + * @return SoapClient + */ + public function getSoapClient() + { + if ($this->_soapClient == null) { + $this->_initSoapClientObject(); + } + return $this->_soapClient; + } + + /** + * @param string $name + * @param string $value + * @return Zend_Soap_Client + */ + public function setCookie($cookieName, $cookieValue=null) + { + $soapClient = $this->getSoapClient(); + $soapClient->__setCookie($cookieName, $cookieValue); + return $this; + } +} diff --git a/library/vendor/Zend/Soap/Client/Common.php b/library/vendor/Zend/Soap/Client/Common.php new file mode 100644 index 0000000..7880115 --- /dev/null +++ b/library/vendor/Zend/Soap/Client/Common.php @@ -0,0 +1,76 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + + +if (extension_loaded('soap')) { + +/** + * @category Zend + * @package Zend_Soap + * @subpackage Client + */ +class Zend_Soap_Client_Common extends SoapClient +{ + /** + * doRequest() pre-processing method + * + * @var callback + */ + protected $_doRequestCallback; + + /** + * Common Soap Client constructor + * + * @param callback $doRequestMethod + * @param string $wsdl + * @param array $options + */ + function __construct($doRequestCallback, $wsdl, $options) + { + $this->_doRequestCallback = $doRequestCallback; + + parent::__construct($wsdl, $options); + } + + /** + * Performs SOAP request over HTTP. + * Overridden to implement different transport layers, perform additional XML processing or other purpose. + * + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + function __doRequest($request, $location, $action, $version, $one_way = null) + { + if ($one_way === null) { + return call_user_func($this->_doRequestCallback, $this, $request, $location, $action, $version); + } else { + return call_user_func($this->_doRequestCallback, $this, $request, $location, $action, $version, $one_way); + } + } + +} + +} // end if (extension_loaded('soap') diff --git a/library/vendor/Zend/Soap/Client/DotNet.php b/library/vendor/Zend/Soap/Client/DotNet.php new file mode 100644 index 0000000..0e6d121 --- /dev/null +++ b/library/vendor/Zend/Soap/Client/DotNet.php @@ -0,0 +1,93 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Soap_Client */ + +if (extension_loaded('soap')) { + +/** + * Zend_Soap_Client_Local + * + * Class is intended to be used with .Net Web Services. + * + * Important! Class is at experimental stage now. + * Please leave your notes, compatiblity issues reports or + * suggestions in fw-webservices@lists.zend.com or fw-general@lists.com + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + */ +class Zend_Soap_Client_DotNet extends Zend_Soap_Client +{ + /** + * Constructor + * + * @param string $wsdl + * @param array $options + */ + public function __construct($wsdl = null, $options = null) + { + // Use SOAP 1.1 as default + $this->setSoapVersion(SOAP_1_1); + + parent::__construct($wsdl, $options); + } + + + /** + * Perform arguments pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + * @throws Zend_Soap_Client_Exception + */ + protected function _preProcessArguments($arguments) + { + if (count($arguments) > 1 || + (count($arguments) == 1 && !is_array(reset($arguments))) + ) { + throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); + } + + // Do nothing + return $arguments; + } + + /** + * Perform result pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessResult($result) + { + $resultProperty = $this->getLastMethod() . 'Result'; + + return $result->$resultProperty; + } + +} + +} // end if (extension_loaded('soap') diff --git a/library/vendor/Zend/Soap/Client/Exception.php b/library/vendor/Zend/Soap/Client/Exception.php new file mode 100644 index 0000000..2c210ed --- /dev/null +++ b/library/vendor/Zend/Soap/Client/Exception.php @@ -0,0 +1,34 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + +/** Zend_Exception */ + +/** + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Soap_Client_Exception extends Zend_Exception +{} + diff --git a/library/vendor/Zend/Soap/Client/Local.php b/library/vendor/Zend/Soap/Client/Local.php new file mode 100644 index 0000000..c060700 --- /dev/null +++ b/library/vendor/Zend/Soap/Client/Local.php @@ -0,0 +1,97 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Soap_Server */ + +/** Zend_Soap_Client */ + +if (extension_loaded('soap')) { + +/** + * Zend_Soap_Client_Local + * + * Class is intended to be used as local SOAP client which works + * with a provided Server object. + * + * Could be used for development or testing purposes. + * + * @category Zend + * @package Zend_Soap + * @subpackage Client + */ +class Zend_Soap_Client_Local extends Zend_Soap_Client +{ + /** + * Server object + * + * @var Zend_Soap_Server + */ + protected $_server; + + /** + * Local client constructor + * + * @param Zend_Soap_Server $server + * @param string $wsdl + * @param array $options + */ + function __construct(Zend_Soap_Server $server, $wsdl, $options = null) + { + $this->_server = $server; + + // Use Server specified SOAP version as default + $this->setSoapVersion($server->getSoapVersion()); + + parent::__construct($wsdl, $options); + } + + /** + * Actual "do request" method. + * + * @internal + * @param Zend_Soap_Client_Common $client + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + { + // Perform request as is + ob_start(); + $this->_server->handle($request); + $response = ob_get_clean(); + + if ($response === null || $response === '') { + $serverResponse = $this->server->getResponse(); + if ($serverResponse !== null) { + $response = $serverResponse; + } + } + + return $response; + } +} + +} // end if (extension_loaded('soap') diff --git a/library/vendor/Zend/Soap/Server.php b/library/vendor/Zend/Soap/Server.php new file mode 100644 index 0000000..9b36815 --- /dev/null +++ b/library/vendor/Zend/Soap/Server.php @@ -0,0 +1,999 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Server + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + +/** + * @see Zend_Server_Interface + */ + +/** @see Zend_Xml_Security */ + +/** @see Zend_Xml_Exception */ + +/** + * Zend_Soap_Server + * + * @category Zend + * @package Zend_Soap + * @subpackage Server + * @uses Zend_Server_Interface + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Soap_Server implements Zend_Server_Interface +{ + /** + * Actor URI + * @var string URI + */ + protected $_actor; + + /** + * Class registered with this server + * @var string + */ + protected $_class; + + /** + * Arguments to pass to {@link $_class} constructor + * @var array + */ + protected $_classArgs = array(); + + /** + * Object registered with this server + */ + protected $_object; + + /** + * Array of SOAP type => PHP class pairings for handling return/incoming values + * @var array + */ + protected $_classmap; + + /** + * Encoding + * @var string + */ + protected $_encoding; + + /** + * SOAP Server Features + * + * @var int + */ + protected $_features; + + /** + * WSDL Caching Options of SOAP Server + * + * @var mixed + */ + protected $_wsdlCache; + + /** + * WS-I compliant + * + * @var boolean + */ + protected $_wsiCompliant; + + /** + * Registered fault exceptions + * @var array + */ + protected $_faultExceptions = array(); + + /** + * Functions registered with this server; may be either an array or the SOAP_FUNCTIONS_ALL + * constant + * @var array|int + */ + protected $_functions = array(); + + /** + * Persistence mode; should be one of the SOAP persistence constants + * @var int + */ + protected $_persistence; + + /** + * Request XML + * @var string + */ + protected $_request; + + /** + * Response XML + * @var string + */ + protected $_response; + + /** + * Flag: whether or not {@link handle()} should return a response instead + * of automatically emitting it. + * @var boolean + */ + protected $_returnResponse = false; + + /** + * SOAP version to use; SOAP_1_2 by default, to allow processing of headers + * @var int + */ + protected $_soapVersion = SOAP_1_2; + + /** + * URI or path to WSDL + * @var string + */ + protected $_wsdl; + + /** + * URI namespace for SOAP server + * @var string URI + */ + protected $_uri; + + /** + * Constructor + * + * Sets display_errors INI setting to off (prevent client errors due to bad + * XML in response). Registers {@link handlePhpErrors()} as error handler + * for E_USER_ERROR. + * + * If $wsdl is provided, it is passed on to {@link setWsdl()}; if any + * options are specified, they are passed on to {@link setOptions()}. + * + * @param string $wsdl + * @param array $options + * @return void + */ + public function __construct($wsdl = null, array $options = null) + { + if (!extension_loaded('soap')) { + throw new Zend_Soap_Server_Exception('SOAP extension is not loaded.'); + } + + if (null !== $wsdl) { + $this->setWsdl($wsdl); + } + + if (null !== $options) { + $this->setOptions($options); + } + } + + /** + * Set Options + * + * Allows setting options as an associative array of option => value pairs. + * + * @param array|Zend_Config $options + * @return Zend_Soap_Server + */ + public function setOptions($options) + { + if($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + foreach ($options as $key => $value) { + switch ($key) { + case 'actor': + $this->setActor($value); + break; + case 'classmap': + case 'classMap': + $this->setClassmap($value); + break; + case 'encoding': + $this->setEncoding($value); + break; + case 'soapVersion': + case 'soap_version': + $this->setSoapVersion($value); + break; + case 'uri': + $this->setUri($value); + break; + 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; + case 'cache_wsdl': + $this->setWsdlCache($value); + break; + case 'wsi_compliant': + $this->setWsiCompliant($value); + break; + default: + break; + } + } + + return $this; + } + + /** + * Return array of options suitable for using with SoapServer constructor + * + * @return array + */ + public function getOptions() + { + $options = array(); + if (null !== $this->_actor) { + $options['actor'] = $this->_actor; + } + + if (null !== $this->_classmap) { + $options['classmap'] = $this->_classmap; + } + + if (null !== $this->_encoding) { + $options['encoding'] = $this->_encoding; + } + + if (null !== $this->_soapVersion) { + $options['soap_version'] = $this->_soapVersion; + } + + if (null !== $this->_uri) { + $options['uri'] = $this->_uri; + } + + if (null !== $this->_features) { + $options['features'] = $this->_features; + } + + if (null !== $this->_wsdlCache) { + $options['cache_wsdl'] = $this->_wsdlCache; + } + + if (null !== $this->_wsiCompliant) { + $options['wsi_compliant'] = $this->_wsiCompliant; + } + + return $options; + } + /** + * Set WS-I compliant + * + * @param boolean $value + * @return Zend_Soap_Server + */ + public function setWsiCompliant($value) + { + if (is_bool($value)) { + $this->_wsiCompliant = $value; + } + return $this; + } + /** + * Gt WS-I compliant + * + * @return boolean + */ + public function getWsiCompliant() + { + return $this->_wsiCompliant; + } + /** + * Set encoding + * + * @param string $encoding + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid encoding argument + */ + public function setEncoding($encoding) + { + if (!is_string($encoding)) { + throw new Zend_Soap_Server_Exception('Invalid encoding specified'); + } + + $this->_encoding = $encoding; + return $this; + } + + /** + * Get encoding + * + * @return string + */ + public function getEncoding() + { + return $this->_encoding; + } + + /** + * Set SOAP version + * + * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid soap version argument + */ + public function setSoapVersion($version) + { + if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { + throw new Zend_Soap_Server_Exception('Invalid soap version specified'); + } + + $this->_soapVersion = $version; + return $this; + } + + /** + * Get SOAP version + * + * @return int + */ + public function getSoapVersion() + { + return $this->_soapVersion; + } + + /** + * Check for valid URN + * + * @param string $urn + * @return true + * @throws Zend_Soap_Server_Exception on invalid URN + */ + public function validateUrn($urn) + { + $scheme = parse_url($urn, PHP_URL_SCHEME); + if ($scheme === false || $scheme === null) { + throw new Zend_Soap_Server_Exception('Invalid URN'); + } + + return true; + } + + /** + * Set actor + * + * Actor is the actor URI for the server. + * + * @param string $actor + * @return Zend_Soap_Server + */ + public function setActor($actor) + { + $this->validateUrn($actor); + $this->_actor = $actor; + return $this; + } + + /** + * Retrieve actor + * + * @return string + */ + public function getActor() + { + return $this->_actor; + } + + /** + * Set URI + * + * URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'. + * + * @param string $uri + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid uri argument + */ + public function setUri($uri) + { + $this->validateUrn($uri); + $this->_uri = $uri; + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getUri() + { + return $this->_uri; + } + + /** + * Set classmap + * + * @param array $classmap + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception for any invalid class in the class map + */ + public function setClassmap($classmap) + { + if (!is_array($classmap)) { + /** + * @see Zend_Soap_Server_Exception + */ + throw new Zend_Soap_Server_Exception('Classmap must be an array'); + } + foreach ($classmap as $type => $class) { + if (!class_exists($class)) { + /** + * @see Zend_Soap_Server_Exception + */ + throw new Zend_Soap_Server_Exception('Invalid class in class map'); + } + } + + $this->_classmap = $classmap; + return $this; + } + + /** + * Retrieve classmap + * + * @return mixed + */ + public function getClassmap() + { + return $this->_classmap; + } + + /** + * Set wsdl + * + * @param string $wsdl URI or path to a WSDL + * @return Zend_Soap_Server + */ + public function setWsdl($wsdl) + { + $this->_wsdl = $wsdl; + return $this; + } + + /** + * Retrieve wsdl + * + * @return string + */ + public function getWsdl() + { + return $this->_wsdl; + } + + /** + * Set the SOAP Feature options. + * + * @param string|int $feature + * @return Zend_Soap_Server + */ + public function setSoapFeatures($feature) + { + $this->_features = $feature; + return $this; + } + + /** + * Return current SOAP Features options + * + * @return int + */ + public function getSoapFeatures() + { + return $this->_features; + } + + /** + * Set the SOAP Wsdl Caching Options + * + * @param string|int|boolean $caching + * @return Zend_Soap_Server + */ + public function setWsdlCache($options) + { + $this->_wsdlCache = $options; + return $this; + } + + /** + * Get current SOAP Wsdl Caching option + */ + public function getWsdlCache() + { + return $this->_wsdlCache; + } + + /** + * Attach a function as a server method + * + * @param array|string $function Function name, array of function names to attach, + * or SOAP_FUNCTIONS_ALL to attach all functions + * @param string $namespace Ignored + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception on invalid functions + */ + public function addFunction($function, $namespace = '') + { + // Bail early if set to SOAP_FUNCTIONS_ALL + if ($this->_functions == SOAP_FUNCTIONS_ALL) { + return $this; + } + + if (is_array($function)) { + foreach ($function as $func) { + if (is_string($func) && function_exists($func)) { + $this->_functions[] = $func; + } else { + throw new Zend_Soap_Server_Exception('One or more invalid functions specified in array'); + } + } + $this->_functions = array_merge($this->_functions, $function); + } elseif (is_string($function) && function_exists($function)) { + $this->_functions[] = $function; + } elseif ($function == SOAP_FUNCTIONS_ALL) { + $this->_functions = SOAP_FUNCTIONS_ALL; + } else { + throw new Zend_Soap_Server_Exception('Invalid function specified'); + } + + if (is_array($this->_functions)) { + $this->_functions = array_unique($this->_functions); + } + + return $this; + } + + /** + * Attach a class to a server + * + * Accepts a class name to use when handling requests. Any additional + * arguments will be passed to that class' constructor when instantiated. + * + * See {@link setObject()} to set preconfigured object instances as request handlers. + * + * @param string $class Class Name which executes SOAP Requests at endpoint. + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception if called more than once, or if class + * does not exist + */ + public function setClass($class, $namespace = '', $argv = null) + { + if (isset($this->_class)) { + throw new Zend_Soap_Server_Exception('A class has already been registered with this soap server instance'); + } + + if (!is_string($class)) { + throw new Zend_Soap_Server_Exception('Invalid class argument (' . gettype($class) . ')'); + } + + if (!class_exists($class)) { + throw new Zend_Soap_Server_Exception('Class "' . $class . '" does not exist'); + } + + $this->_class = $class; + if (1 < func_num_args()) { + $argv = func_get_args(); + array_shift($argv); + $this->_classArgs = $argv; + } + + return $this; + } + + /** + * Attach an object to a server + * + * Accepts an instanciated object to use when handling requests. + * + * @param object $object + * @return Zend_Soap_Server + */ + public function setObject($object) + { + if(!is_object($object)) { + throw new Zend_Soap_Server_Exception('Invalid object argument ('.gettype($object).')'); + } + + if(isset($this->_object)) { + throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); + } + + if ($this->_wsiCompliant) { + $this->_object = new Zend_Soap_Server_Proxy($object); + } else { + $this->_object = $object; + } + + return $this; + } + + /** + * Return a server definition array + * + * Returns a list of all functions registered with {@link addFunction()}, + * merged with all public methods of the class set with {@link setClass()} + * (if any). + * + * @access public + * @return array + */ + public function getFunctions() + { + $functions = array(); + if (null !== $this->_class) { + $functions = get_class_methods($this->_class); + } elseif (null !== $this->_object) { + $functions = get_class_methods($this->_object); + } + + return array_merge((array) $this->_functions, $functions); + } + + /** + * Unimplemented: Load server definition + * + * @param array $array + * @return void + * @throws Zend_Soap_Server_Exception Unimplemented + */ + public function loadFunctions($definition) + { + throw new Zend_Soap_Server_Exception('Unimplemented'); + } + + /** + * Set server persistence + * + * @param int $mode + * @return Zend_Soap_Server + */ + public function setPersistence($mode) + { + if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) { + throw new Zend_Soap_Server_Exception('Invalid persistence mode specified'); + } + + $this->_persistence = $mode; + return $this; + } + + /** + * Get server persistence + * + * @return Zend_Soap_Server + */ + public function getPersistence() + { + return $this->_persistence; + } + + /** + * Set request + * + * $request may be any of: + * - DOMDocument; if so, then cast to XML + * - DOMNode; if so, then grab owner document and cast to XML + * - SimpleXMLElement; if so, then cast to XML + * - stdClass; if so, calls __toString() and verifies XML + * - string; if so, verifies XML + * + * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request + * @return Zend_Soap_Server + */ + protected function _setRequest($request) + { + if ($request instanceof DOMDocument) { + $xml = $request->saveXML(); + } elseif ($request instanceof DOMNode) { + $xml = $request->ownerDocument->saveXML(); + } elseif ($request instanceof SimpleXMLElement) { + $xml = $request->asXML(); + } elseif (is_object($request) || is_string($request)) { + if (is_object($request)) { + $xml = $request->__toString(); + } else { + $xml = $request; + } + + $dom = new DOMDocument(); + try { + if(strlen($xml) == 0 || (!$dom = Zend_Xml_Security::scan($xml, $dom))) { + throw new Zend_Soap_Server_Exception('Invalid XML'); + } + } catch (Zend_Xml_Exception $e) { + throw new Zend_Soap_Server_Exception( + $e->getMessage() + ); + } + } + $this->_request = $xml; + return $this; + } + + /** + * Retrieve request XML + * + * @return string + */ + public function getLastRequest() + { + return $this->_request; + } + + /** + * Set return response flag + * + * If true, {@link handle()} will return the response instead of + * automatically sending it back to the requesting client. + * + * The response is always available via {@link getResponse()}. + * + * @param boolean $flag + * @return Zend_Soap_Server + */ + public function setReturnResponse($flag) + { + $this->_returnResponse = ($flag) ? true : false; + return $this; + } + + /** + * Retrieve return response flag + * + * @return boolean + */ + public function getReturnResponse() + { + return $this->_returnResponse; + } + + /** + * Get response XML + * + * @return string + */ + public function getLastResponse() + { + return $this->_response; + } + + /** + * Get SoapServer object + * + * Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate + * SoapServer object, and then registers any functions or class with it, as + * well as peristence. + * + * @return SoapServer + */ + protected function _getSoap() + { + $options = $this->getOptions(); + $server = new SoapServer($this->_wsdl, $options); + + if (!empty($this->_functions)) { + $server->addFunction($this->_functions); + } + + if (!empty($this->_class)) { + $args = $this->_classArgs; + array_unshift($args, $this->_class); + if ($this->_wsiCompliant) { + array_unshift($args, 'Zend_Soap_Server_Proxy'); + } + call_user_func_array(array($server, 'setClass'), $args); + } + + if (!empty($this->_object)) { + $server->setObject($this->_object); + } + + if (null !== $this->_persistence) { + $server->setPersistence($this->_persistence); + } + + return $server; + } + + /** + * Handle a request + * + * Instantiates SoapServer object with options set in object, and + * dispatches its handle() method. + * + * $request may be any of: + * - DOMDocument; if so, then cast to XML + * - DOMNode; if so, then grab owner document and cast to XML + * - SimpleXMLElement; if so, then cast to XML + * - stdClass; if so, calls __toString() and verifies XML + * - string; if so, verifies XML + * + * If no request is passed, pulls request using php:://input (for + * cross-platform compatability purposes). + * + * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request Optional request + * @return void|string + */ + public function handle($request = null) + { + if (null === $request) { + $request = file_get_contents('php://input'); + } + + // Set Zend_Soap_Server error handler + $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); + + $setRequestException = null; + /** + * @see Zend_Soap_Server_Exception + */ + try { + $this->_setRequest($request); + } catch (Zend_Soap_Server_Exception $e) { + $setRequestException = $e; + } + + $soap = $this->_getSoap(); + + $fault = false; + ob_start(); + if ($setRequestException instanceof Exception) { + // Create SOAP fault message if we've caught a request exception + $fault = $this->fault($setRequestException->getMessage(), 'Sender'); + } else { + try { + $soap->handle($this->_request); + } catch (Exception $e) { + $fault = $this->fault($e); + } + } + $this->_response = ob_get_clean(); + + // Restore original error handler + restore_error_handler(); + ini_set('display_errors', $displayErrorsOriginalState); + + // Send a fault, if we have one + if ($fault) { + $soap->fault($fault->faultcode, $fault->faultstring); + } + + if (!$this->_returnResponse) { + echo $this->_response; + return; + } + + return $this->_response; + } + + /** + * Method initalizes the error context that the SOAPServer enviroment will run in. + * + * @return boolean display_errors original value + */ + protected function _initializeSoapErrorContext() + { + $displayErrorsOriginalState = ini_get('display_errors'); + ini_set('display_errors', false); + set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR); + return $displayErrorsOriginalState; + } + + /** + * Register a valid fault exception + * + * @param string|array $class Exception class or array of exception classes + * @return Zend_Soap_Server + */ + public function registerFaultException($class) + { + $this->_faultExceptions = array_merge($this->_faultExceptions, (array) $class); + return $this; + } + + /** + * Deregister a fault exception from the fault exception stack + * + * @param string $class + * @return boolean + */ + public function deregisterFaultException($class) + { + if (in_array($class, $this->_faultExceptions, true)) { + $index = array_search($class, $this->_faultExceptions); + unset($this->_faultExceptions[$index]); + return true; + } + + return false; + } + + /** + * Return fault exceptions list + * + * @return array + */ + public function getFaultExceptions() + { + return $this->_faultExceptions; + } + + /** + * Generate a server fault + * + * Note that the arguments are reverse to those of SoapFault. + * + * If an exception is passed as the first argument, its message and code + * will be used to create the fault object if it has been registered via + * {@Link registerFaultException()}. + * + * @link http://www.w3.org/TR/soap12-part1/#faultcodes + * @param string|Exception $fault + * @param string $code SOAP Fault Codes + * @return SoapFault + */ + public function fault($fault = null, $code = "Receiver") + { + if ($fault instanceof Exception) { + $class = get_class($fault); + if (in_array($class, $this->_faultExceptions)) { + $message = $fault->getMessage(); + $eCode = $fault->getCode(); + $code = empty($eCode) ? $code : $eCode; + } else { + $message = 'Unknown error'; + } + } elseif(is_string($fault)) { + $message = $fault; + } else { + $message = 'Unknown error'; + } + + $allowedFaultModes = array( + 'VersionMismatch', 'MustUnderstand', 'DataEncodingUnknown', + 'Sender', 'Receiver', 'Server' + ); + if(!in_array($code, $allowedFaultModes)) { + $code = "Receiver"; + } + + return new SoapFault($code, $message); + } + + /** + * Throw PHP errors as SoapFaults + * + * @param int $errno + * @param string $errstr + * @param string $errfile + * @param int $errline + * @param array $errcontext + * @return void + * @throws SoapFault + */ + public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null) + { + throw $this->fault($errstr, "Receiver"); + } +} diff --git a/library/vendor/Zend/Soap/Server/Exception.php b/library/vendor/Zend/Soap/Server/Exception.php new file mode 100644 index 0000000..29e4554 --- /dev/null +++ b/library/vendor/Zend/Soap/Server/Exception.php @@ -0,0 +1,36 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Server + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + + +/** Zend_Exception */ + + +/** + * @category Zend + * @package Zend_Soap + * @subpackage Server + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Soap_Server_Exception extends Zend_Exception +{} + diff --git a/library/vendor/Zend/Soap/Server/Proxy.php b/library/vendor/Zend/Soap/Server/Proxy.php new file mode 100644 index 0000000..addecd1 --- /dev/null +++ b/library/vendor/Zend/Soap/Server/Proxy.php @@ -0,0 +1,75 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage AutoDiscover + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +class Zend_Soap_Server_Proxy +{ + /** + * @var object + */ + protected $_classInstance; + /** + * @var string + */ + protected $_className; + /** + * Constructor + * + * @param object $service + */ + public function __construct($className, $classArgs = array()) + { + $class = new ReflectionClass($className); + $constructor = $class->getConstructor(); + if ($constructor === null) { + $this->_classInstance = $class->newInstance(); + } else { + $this->_classInstance = $class->newInstanceArgs(array_values($classArgs)); + } + $this->_className = $className; + } + /** + * Proxy for the WS-I compliant call + * + * @param string $name + * @param string $arguments + * @return array + */ + public function __call($name, $arguments) + { + $result = call_user_func_array(array($this->_classInstance, $name), $this->_preProcessArguments($arguments)); + return array("{$name}Result"=>$result); + } + /** + * Pre process arguments + * + * @param mixed $arguments + * @return array + */ + protected function _preProcessArguments($arguments) + { + if (count($arguments) == 1 && is_object($arguments[0])) { + return get_object_vars($arguments[0]); + } else { + return $arguments; + } + } +} diff --git a/library/vendor/Zend/Soap/Wsdl.php b/library/vendor/Zend/Soap/Wsdl.php new file mode 100644 index 0000000..95f2c20 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl.php @@ -0,0 +1,661 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Abstract + */ + +/** @see Zend_Xml_Security */ + +/** + * Zend_Soap_Wsdl + * + * @category Zend + * @package Zend_Soap + */ +class Zend_Soap_Wsdl +{ + /** + * @var object DomDocument Instance + */ + private $_dom; + + /** + * @var object WSDL Root XML_Tree_Node + */ + private $_wsdl; + + /** + * @var string URI where the WSDL will be available + */ + private $_uri; + + /** + * @var DOMElement + */ + private $_schema = null; + + /** + * Types defined on schema + * + * @var array + */ + private $_includedTypes = array(); + + /** + * Strategy for detection of complex types + */ + protected $_strategy = null; + + + /** + * Constructor + * + * @param string $name Name of the Web Service being Described + * @param string $uri URI where the WSDL will be available + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + */ + public function __construct($name, $uri, $strategy = true) + { + if ($uri instanceof Zend_Uri_Http) { + $uri = $uri->getUri(); + } + $this->_uri = $uri; + + /** + * @todo change DomDocument object creation from cparsing to construxting using API + * It also should authomatically escape $name and $uri values if necessary + */ + $wsdl = "<?xml version='1.0' ?> + <definitions name='$name' targetNamespace='$uri' + xmlns='http://schemas.xmlsoap.org/wsdl/' + xmlns:tns='$uri' + xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' + xmlns:xsd='http://www.w3.org/2001/XMLSchema' + xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/' + xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'></definitions>"; + $this->_dom = new DOMDocument(); + if (!$this->_dom = Zend_Xml_Security::scan($wsdl, $this->_dom)) { + throw new Zend_Server_Exception('Unable to create DomDocument'); + } + $this->_wsdl = $this->_dom->documentElement; + + $this->setComplexTypeStrategy($strategy); + } + + /** + * Set a new uri for this WSDL + * + * @param string|Zend_Uri_Http $uri + * @return Zend_Server_Wsdl + */ + public function setUri($uri) + { + if ($uri instanceof Zend_Uri_Http) { + $uri = $uri->getUri(); + } + $oldUri = $this->_uri; + $this->_uri = $uri; + + if($this->_dom !== null) { + // @todo: This is the worst hack ever, but its needed due to design and non BC issues of WSDL generation + $xml = $this->_dom->saveXML(); + $xml = str_replace($oldUri, $uri, $xml); + $this->_dom = new DOMDocument(); + $this->_dom = Zend_Xml_Security::scan($xml, $this->_dom); + } + + return $this; + } + + /** + * Set a strategy for complex type detection and handling + * + * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions. + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_Wsdl + */ + public function setComplexTypeStrategy($strategy) + { + if($strategy === true) { + $strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); + } else if($strategy === false) { + $strategy = new Zend_Soap_Wsdl_Strategy_AnyType(); + } else if(is_string($strategy)) { + if(class_exists($strategy)) { + $strategy = new $strategy(); + } else { + throw new Zend_Soap_Wsdl_Exception( + sprintf("Strategy with name '%s does not exist.", $strategy + )); + } + } + + if(!($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface)) { + throw new Zend_Soap_Wsdl_Exception("Set a strategy that is not of type 'Zend_Soap_Wsdl_Strategy_Interface'"); + } + $this->_strategy = $strategy; + return $this; + } + + /** + * Get the current complex type strategy + * + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getComplexTypeStrategy() + { + return $this->_strategy; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_messages message} element to the WSDL + * + * @param string $name Name for the {@link http://www.w3.org/TR/wsdl#_messages message} + * @param array $parts An array of {@link http://www.w3.org/TR/wsdl#_message parts} + * The array is constructed like: 'name of part' => 'part xml schema data type' + * or 'name of part' => array('type' => 'part xml schema type') + * or 'name of part' => array('element' => 'part xml element name') + * @return object The new message's XML_Tree_Node for use in {@link function addDocumentation} + */ + public function addMessage($name, $parts) + { + $message = $this->_dom->createElement('message'); + + $message->setAttribute('name', $name); + + if (sizeof($parts) > 0) { + foreach ($parts as $name => $type) { + $part = $this->_dom->createElement('part'); + $part->setAttribute('name', $name); + if (is_array($type)) { + foreach ($type as $key => $value) { + $part->setAttribute($key, $value); + } + } else { + $part->setAttribute('type', $type); + } + $message->appendChild($part); + } + } + + $this->_wsdl->appendChild($message); + + return $message; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_porttypes portType} element to the WSDL + * + * @param string $name portType element's name + * @return object The new portType's XML_Tree_Node for use in {@link function addPortOperation} and {@link function addDocumentation} + */ + public function addPortType($name) + { + $portType = $this->_dom->createElement('portType'); + $portType->setAttribute('name', $name); + $this->_wsdl->appendChild($portType); + + return $portType; + } + + /** + * Add an {@link http://www.w3.org/TR/wsdl#_request-response operation} element to a portType element + * + * @param object $portType a portType XML_Tree_Node, from {@link function addPortType} + * @param string $name Operation name + * @param string $input Input Message + * @param string $output Output Message + * @param string $fault Fault Message + * @return object The new operation's XML_Tree_Node for use in {@link function addDocumentation} + */ + public function addPortOperation($portType, $name, $input = false, $output = false, $fault = false) + { + $operation = $this->_dom->createElement('operation'); + $operation->setAttribute('name', $name); + + if (is_string($input) && (strlen(trim($input)) >= 1)) { + $node = $this->_dom->createElement('input'); + $node->setAttribute('message', $input); + $operation->appendChild($node); + } + if (is_string($output) && (strlen(trim($output)) >= 1)) { + $node= $this->_dom->createElement('output'); + $node->setAttribute('message', $output); + $operation->appendChild($node); + } + if (is_string($fault) && (strlen(trim($fault)) >= 1)) { + $node = $this->_dom->createElement('fault'); + $node->setAttribute('message', $fault); + $operation->appendChild($node); + } + + $portType->appendChild($operation); + + return $operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_bindings binding} element to WSDL + * + * @param string $name Name of the Binding + * @param string $type name of the portType to bind + * @return object The new binding's XML_Tree_Node for use with {@link function addBindingOperation} and {@link function addDocumentation} + */ + public function addBinding($name, $portType) + { + $binding = $this->_dom->createElement('binding'); + $binding->setAttribute('name', $name); + $binding->setAttribute('type', $portType); + + $this->_wsdl->appendChild($binding); + + return $binding; + } + + /** + * Add an operation to a binding element + * + * @param object $binding A binding XML_Tree_Node returned by {@link function addBinding} + * @param array $input An array of attributes for the input element, allowed keys are: 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @param array $output An array of attributes for the output element, allowed keys are: 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @param array $fault An array of attributes for the fault element, allowed keys are: 'name', 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @return object The new Operation's XML_Tree_Node for use with {@link function addSoapOperation} and {@link function addDocumentation} + */ + public function addBindingOperation($binding, $name, $input = false, $output = false, $fault = false) + { + $operation = $this->_dom->createElement('operation'); + $operation->setAttribute('name', $name); + + if (is_array($input)) { + $node = $this->_dom->createElement('input'); + $soap_node = $this->_dom->createElement('soap:body'); + foreach ($input as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + if (is_array($output)) { + $node = $this->_dom->createElement('output'); + $soap_node = $this->_dom->createElement('soap:body'); + foreach ($output as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + if (is_array($fault)) { + $node = $this->_dom->createElement('fault'); + /** + * Note. Do we really need name attribute to be also set at wsdl:fault node??? + * W3C standard doesn't mention it (http://www.w3.org/TR/wsdl#_soap:fault) + * But some real world WSDLs use it, so it may be required for compatibility reasons. + */ + if (isset($fault['name'])) { + $node->setAttribute('name', $fault['name']); + } + + $soap_node = $this->_dom->createElement('soap:fault'); + foreach ($fault as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + $binding->appendChild($operation); + + return $operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_soap:binding SOAP binding} element to a Binding element + * + * @param object $binding A binding XML_Tree_Node returned by {@link function addBinding} + * @param string $style binding style, possible values are "rpc" (the default) and "document" + * @param string $transport Transport method (defaults to HTTP) + * @return boolean + */ + public function addSoapBinding($binding, $style = 'document', $transport = 'http://schemas.xmlsoap.org/soap/http') + { + $soap_binding = $this->_dom->createElement('soap:binding'); + $soap_binding->setAttribute('style', $style); + $soap_binding->setAttribute('transport', $transport); + + $binding->appendChild($soap_binding); + + return $soap_binding; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_soap:operation SOAP operation} to an operation element + * + * @param object $operation An operation XML_Tree_Node returned by {@link function addBindingOperation} + * @param string $soap_action SOAP Action + * @return boolean + */ + public function addSoapOperation($binding, $soap_action) + { + if ($soap_action instanceof Zend_Uri_Http) { + $soap_action = $soap_action->getUri(); + } + $soap_operation = $this->_dom->createElement('soap:operation'); + $soap_operation->setAttribute('soapAction', $soap_action); + + $binding->insertBefore($soap_operation, $binding->firstChild); + + return $soap_operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_services service} element to the WSDL + * + * @param string $name Service Name + * @param string $port_name Name of the port for the service + * @param string $binding Binding for the port + * @param string $location SOAP Address for the service + * @return object The new service's XML_Tree_Node for use with {@link function addDocumentation} + */ + public function addService($name, $port_name, $binding, $location) + { + if ($location instanceof Zend_Uri_Http) { + $location = $location->getUri(); + } + $service = $this->_dom->createElement('service'); + $service->setAttribute('name', $name); + + $port = $this->_dom->createElement('port'); + $port->setAttribute('name', $port_name); + $port->setAttribute('binding', $binding); + + $soap_address = $this->_dom->createElement('soap:address'); + $soap_address->setAttribute('location', $location); + + $port->appendChild($soap_address); + $service->appendChild($port); + + $this->_wsdl->appendChild($service); + + return $service; + } + + /** + * Add a documentation element to any element in the WSDL. + * + * Note that the WSDL {@link http://www.w3.org/TR/wsdl#_documentation specification} uses 'document', + * but the WSDL {@link http://schemas.xmlsoap.org/wsdl/ schema} uses 'documentation' instead. + * The {@link http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#WSDL_documentation_Element WS-I Basic Profile 1.1} recommends using 'documentation'. + * + * @param object $input_node An XML_Tree_Node returned by another method to add the documentation to + * @param string $documentation Human readable documentation for the node + * @return DOMElement The documentation element + */ + public function addDocumentation($input_node, $documentation) + { + if ($input_node === $this) { + $node = $this->_dom->documentElement; + } else { + $node = $input_node; + } + + $doc = $this->_dom->createElement('documentation'); + $doc_cdata = $this->_dom->createTextNode(str_replace(array("\r\n", "\r"), "\n", $documentation)); + $doc->appendChild($doc_cdata); + + if($node->hasChildNodes()) { + $node->insertBefore($doc, $node->firstChild); + } else { + $node->appendChild($doc); + } + + return $doc; + } + + /** + * Add WSDL Types element + * + * @param object $types A DomDocument|DomNode|DomElement|DomDocumentFragment with all the XML Schema types defined in it + */ + public function addTypes($types) + { + if ($types instanceof DomDocument) { + $dom = $this->_dom->importNode($types->documentElement); + $this->_wsdl->appendChild($types->documentElement); + } elseif ($types instanceof DomNode || $types instanceof DomElement || $types instanceof DomDocumentFragment ) { + $dom = $this->_dom->importNode($types); + $this->_wsdl->appendChild($dom); + } + } + + /** + * Add a complex type name that is part of this WSDL and can be used in signatures. + * + * @param string $type + * @return Zend_Soap_Wsdl + */ + public function addType($type) + { + if(!in_array($type, $this->_includedTypes)) { + $this->_includedTypes[] = $type; + } + return $this; + } + + /** + * Return an array of all currently included complex types + * + * @return array + */ + public function getTypes() + { + return $this->_includedTypes; + } + + /** + * Return the Schema node of the WSDL + * + * @return DOMElement + */ + public function getSchema() + { + if($this->_schema == null) { + $this->addSchemaTypeSection(); + } + + return $this->_schema; + } + + /** + * Return the WSDL as XML + * + * @return string WSDL as XML + */ + public function toXML() + { + return $this->_dom->saveXML(); + } + + /** + * Return DOM Document + * + * @return object DomDocum ent + */ + public function toDomDocument() + { + return $this->_dom; + } + + /** + * Echo the WSDL as XML + * + * @return boolean + */ + public function dump($filename = false) + { + if (!$filename) { + echo $this->toXML(); + return true; + } else { + return file_put_contents($filename, $this->toXML()); + } + } + + /** + * Returns an XSD Type for the given PHP type + * + * @param string $type PHP Type to get the XSD type for + * @return string + */ + public function getType($type) + { + switch (strtolower($type)) { + case 'string': + case 'str': + return 'xsd:string'; + case 'long': + return 'xsd:long'; + case 'int': + case 'integer': + return 'xsd:int'; + case 'float': + return 'xsd:float'; + case 'double': + return 'xsd:double'; + case 'boolean': + case 'bool': + return 'xsd:boolean'; + case 'array': + return 'soap-enc:Array'; + case 'object': + return 'xsd:struct'; + case 'mixed': + return 'xsd:anyType'; + case 'void': + return ''; + default: + // delegate retrieval of complex type to current strategy + return $this->addComplexType($type); + } + } + + /** + * This function makes sure a complex types section and schema additions are set. + * + * @return Zend_Soap_Wsdl + */ + public function addSchemaTypeSection() + { + if ($this->_schema === null) { + $this->_schema = $this->_dom->createElement('xsd:schema'); + $this->_schema->setAttribute('targetNamespace', $this->_uri); + $types = $this->_dom->createElement('types'); + $types->appendChild($this->_schema); + $this->_wsdl->appendChild($types); + } + return $this; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition + * + * @param string $type Name of the class to be specified + * @return string XSD Type for the given PHP type + */ + public function addComplexType($type) + { + if (in_array($type, $this->getTypes())) { + return "tns:$type"; + } + $this->addSchemaTypeSection(); + + $strategy = $this->getComplexTypeStrategy(); + $strategy->setContext($this); + // delegates the detection of a complex type to the current strategy + return $strategy->addComplexType($type); + } + + /** + * Parse an xsd:element represented as an array into a DOMElement. + * + * @param array $element an xsd:element represented as an array + * @return DOMElement parsed element + */ + private function _parseElement($element) + { + if (!is_array($element)) { + throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array."); + } + + $elementXml = $this->_dom->createElement('xsd:element'); + foreach ($element as $key => $value) { + if (in_array($key, array('sequence', 'all', 'choice'))) { + if (is_array($value)) { + $complexType = $this->_dom->createElement('xsd:complexType'); + if (count($value) > 0) { + $container = $this->_dom->createElement('xsd:' . $key); + foreach ($value as $subelement) { + $subelementXml = $this->_parseElement($subelement); + $container->appendChild($subelementXml); + } + $complexType->appendChild($container); + } + $elementXml->appendChild($complexType); + } + } else { + $elementXml->setAttribute($key, $value); + } + } + return $elementXml; + } + + /** + * Add an xsd:element represented as an array to the schema. + * + * Array keys represent attribute names and values their respective value. + * The 'sequence', 'all' and 'choice' keys must have an array of elements as their value, + * to add them to a nested complexType. + * + * Example: array( 'name' => 'MyElement', + * 'sequence' => array( array('name' => 'myString', 'type' => 'string'), + * array('name' => 'myInteger', 'type' => 'int') ) ); + * Resulting XML: <xsd:element name="MyElement"><xsd:complexType><xsd:sequence> + * <xsd:element name="myString" type="string"/> + * <xsd:element name="myInteger" type="int"/> + * </xsd:sequence></xsd:complexType></xsd:element> + * + * @param array $element an xsd:element represented as an array + * @return string xsd:element for the given element array + */ + public function addElement($element) + { + $schema = $this->getSchema(); + $elementXml = $this->_parseElement($element); + $schema->appendChild($elementXml); + return 'tns:' . $element['name']; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Exception.php b/library/vendor/Zend/Soap/Wsdl/Exception.php new file mode 100644 index 0000000..11397f0 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Exception.php @@ -0,0 +1,36 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Exception + */ + +/** + * Zend_Soap_Wsdl_Exception + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Exception extends Zend_Exception { } diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/Abstract.php b/library/vendor/Zend/Soap/Wsdl/Strategy/Abstract.php new file mode 100644 index 0000000..35f198f --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/Abstract.php @@ -0,0 +1,65 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ + +/** + * Abstract class for Zend_Soap_Wsdl_Strategy. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface +{ + /** + * Context object + * + * @var Zend_Soap_Wsdl + */ + protected $_context; + + /** + * Set the Zend_Soap_Wsdl Context object this strategy resides in. + * + * @param Zend_Soap_Wsdl $context + * @return void + */ + public function setContext(Zend_Soap_Wsdl $context) + { + $this->_context = $context; + } + + /** + * Return the current Zend_Soap_Wsdl context object + * + * @return Zend_Soap_Wsdl + */ + public function getContext() + { + return $this->_context; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php b/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php new file mode 100644 index 0000000..13f352e --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php @@ -0,0 +1,58 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ + +/** + * Zend_Soap_Wsdl_Strategy_AnyType + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface +{ + /** + * Not needed in this strategy. + * + * @param Zend_Soap_Wsdl $context + */ + public function setContext(Zend_Soap_Wsdl $context) + { + + } + + /** + * Returns xsd:anyType regardless of the input. + * + * @param string $type + * @return string + */ + public function addComplexType($type) + { + return 'xsd:anyType'; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php new file mode 100644 index 0000000..a830840 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -0,0 +1,142 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType + */ + +/** + * Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType +{ + protected $_inProcess = array(); + + /** + * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment. + * + * @param string $type + * @return string tns:xsd-type + */ + public function addComplexType($type) + { + if (in_array($type, $this->_inProcess)) { + return "tns:" . $type; + } + $this->_inProcess[$type] = $type; + + $nestingLevel = $this->_getNestedCount($type); + + if($nestingLevel > 1) { + throw new Zend_Soap_Wsdl_Exception( + "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ". + "one level. Use array object properties to return deep nested data. + "); + } + + $singularType = $this->_getSingularPhpType($type); + + if(!class_exists($singularType)) { + throw new Zend_Soap_Wsdl_Exception(sprintf( + "Cannot add a complex type %s that is not an object or where ". + "class could not be found in 'DefaultComplexType' strategy.", $type + )); + } + + if($nestingLevel == 1) { + // The following blocks define the Array of Object structure + $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type); + } else { + $xsdComplexTypeName = $singularType; + } + + // The array for the objects has been created, now build the object definition: + if(!in_array($singularType, $this->getContext()->getTypes())) { + parent::addComplexType($singularType); + } + + unset($this->_inProcess[$type]); + return "tns:".$xsdComplexTypeName; + } + + protected function _addArrayOfComplexType($singularType, $type) + { + $dom = $this->getContext()->toDomDocument(); + + $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); + + if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) { + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $xsdComplexTypeName); + + $complexContent = $dom->createElement("xsd:complexContent"); + $complexType->appendChild($complexContent); + + $xsdRestriction = $dom->createElement("xsd:restriction"); + $xsdRestriction->setAttribute('base', 'soap-enc:Array'); + $complexContent->appendChild($xsdRestriction); + + $xsdAttribute = $dom->createElement("xsd:attribute"); + $xsdAttribute->setAttribute("ref", "soap-enc:arrayType"); + $xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType)); + $xsdRestriction->appendChild($xsdAttribute); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($xsdComplexTypeName); + } + + return $xsdComplexTypeName; + } + + protected function _getXsdComplexTypeName($type) + { + return sprintf('ArrayOf%s', $type); + } + + /** + * From a nested definition with type[], get the singular PHP Type + * + * @param string $type + * @return string + */ + protected function _getSingularPhpType($type) + { + return str_replace("[]", "", $type); + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php new file mode 100644 index 0000000..e82ea50 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -0,0 +1,154 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType + */ + +/** + * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType +{ + /** + * Add an unbounded ArrayOfType based on the xsd:sequence syntax if type[] is detected in return value doc comment. + * + * @param string $type + * @return string tns:xsd-type + */ + public function addComplexType($type) + { + $nestedCounter = $this->_getNestedCount($type); + + if($nestedCounter > 0) { + $singularType = $this->_getSingularType($type); + + for($i = 1; $i <= $nestedCounter; $i++) { + $complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4); + $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); + + $this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName); + } + // adding the PHP type which is resolved to a nested XSD type. therefore add only once. + $this->getContext()->addType($complexTypeName); + + return "tns:$complexTypeName"; + } else if (!in_array($type, $this->getContext()->getTypes())) { + // New singular complex type + return parent::addComplexType($type); + } else { + // Existing complex type + return $this->getContext()->getType($type); + } + } + + /** + * Return the ArrayOf or simple type name based on the singular xsdtype and the nesting level + * + * @param string $singularType + * @param int $level + * @return string + */ + protected function _getTypeNameBasedOnNestingLevel($singularType, $level) + { + if($level == 0) { + // This is not an Array anymore, return the xsd simple type + return $singularType; + } else { + $prefix = str_repeat("ArrayOf", $level); + $xsdType = $this->_getStrippedXsdType($singularType); + $arrayType = $prefix.$xsdType; + return "tns:$arrayType"; + } + } + + /** + * Strip the xsd: from a singularType and Format it nice for ArrayOf<Type> naming + * + * @param string $singularType + * @return string + */ + protected function _getStrippedXsdType($singularType) + { + return ucfirst(substr(strtolower($singularType), 4)); + } + + /** + * From a nested defintion with type[], get the singular xsd:type + * + * @throws Zend_Soap_Wsdl_Exception When no xsd:simpletype can be detected. + * @param string $type + * @return string + */ + protected function _getSingularType($type) + { + $singulartype = $this->getContext()->getType(str_replace("[]", "", $type)); + return $singulartype; + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } + + /** + * Append the complex type definition to the WSDL via the context access + * + * @param string $arrayType + * @param string $childTypeName + * @return void + */ + protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName) + { + if (!in_array($arrayType, $this->getContext()->getTypes())) { + $dom = $this->getContext()->toDomDocument(); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $arrayType); + + $sequence = $dom->createElement('xsd:sequence'); + + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', 'item'); + $element->setAttribute('type', $childTypeName); + $element->setAttribute('minOccurs', 0); + $element->setAttribute('maxOccurs', 'unbounded'); + $sequence->appendChild($element); + + $complexType->appendChild($sequence); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($arrayType); + } + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php b/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php new file mode 100644 index 0000000..a80120e --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php @@ -0,0 +1,183 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ + +/** + * Zend_Soap_Wsdl_Strategy_Composite + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface +{ + /** + * Typemap of Complex Type => Strategy pairs. + * + * @var array + */ + protected $_typeMap = array(); + + /** + * Default Strategy of this composite + * + * @var string|Zend_Soap_Wsdl_Strategy_Interface + */ + protected $_defaultStrategy; + + /** + * Context WSDL file that this composite serves + * + * @var Zend_Soap_Wsdl|null + */ + protected $_context; + + /** + * Construct Composite WSDL Strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param array $typeMap + * @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy + */ + public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType") + { + foreach($typeMap AS $type => $strategy) { + $this->connectTypeToStrategy($type, $strategy); + } + $this->_defaultStrategy = $defaultStrategy; + } + + /** + * Connect a complex type to a given strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_Wsdl_Strategy_Composite + */ + public function connectTypeToStrategy($type, $strategy) + { + if(!is_string($type)) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map."); + } + $this->_typeMap[$type] = $strategy; + return $this; + } + + /** + * Return default strategy of this composite + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getDefaultStrategy() + { + $strategy = $this->_defaultStrategy; + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy; + } + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Default Strategy for Complex Types is not a valid strategy object." + ); + } + $this->_defaultStrategy = $strategy; + return $strategy; + } + + /** + * Return specific strategy or the default strategy of this type. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getStrategyOfType($type) + { + if(isset($this->_typeMap[$type])) { + $strategy = $this->_typeMap[$type]; + + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy(); + } + + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Strategy for Complex Type '".$type."' is not a valid strategy object." + ); + } + $this->_typeMap[$type] = $strategy; + } else { + $strategy = $this->getDefaultStrategy(); + } + return $strategy; + } + + /** + * Method accepts the current WSDL context file. + * + * @param Zend_Soap_Wsdl $context + */ + public function setContext(Zend_Soap_Wsdl $context) + { + $this->_context = $context; + return $this; + } + + /** + * Create a complex type based on a strategy + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return string XSD type + */ + public function addComplexType($type) + { + if(!($this->_context instanceof Zend_Soap_Wsdl) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Cannot add complex type '".$type."', no context is set for this composite strategy." + ); + } + + $strategy = $this->getStrategyOfType($type); + $strategy->setContext($this->_context); + return $strategy->addComplexType($type); + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php b/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php new file mode 100644 index 0000000..3baf804 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php @@ -0,0 +1,89 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @see Zend_Soap_Wsdl_Strategy_Abstract + */ + +/** + * Zend_Soap_Wsdl_Strategy_DefaultComplexType + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract +{ + /** + * Add a complex type by recursivly using all the class properties fetched via Reflection. + * + * @param string $type Name of the class to be specified + * @return string XSD Type for the given PHP type + */ + public function addComplexType($type) + { + if(!class_exists($type)) { + throw new Zend_Soap_Wsdl_Exception(sprintf( + "Cannot add a complex type %s that is not an object or where ". + "class could not be found in 'DefaultComplexType' strategy.", $type + )); + } + + $dom = $this->getContext()->toDomDocument(); + $class = new ReflectionClass($type); + + $defaultProperties = $class->getDefaultProperties(); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $type); + + $all = $dom->createElement('xsd:all'); + + foreach ($class->getProperties() as $property) { + if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) { + + /** + * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType' + * node for describing other classes used as attribute types for current class + */ + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', $propertyName = $property->getName()); + $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); + + // If the default value is null, then this property is nillable. + if ($defaultProperties[$propertyName] === null) { + $element->setAttribute('nillable', 'true'); + } + + $all->appendChild($element); + } + } + + $complexType->appendChild($all); + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($type); + + return "tns:$type"; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php b/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php new file mode 100644 index 0000000..9a57605 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php @@ -0,0 +1,48 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * Interface for Zend_Soap_Wsdl_Strategy. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +interface Zend_Soap_Wsdl_Strategy_Interface +{ + /** + * Method accepts the current WSDL context file. + * + * @param <type> $context + */ + public function setContext(Zend_Soap_Wsdl $context); + + /** + * Create a complex type based on a strategy + * + * @param string $type + * @return string XSD type + */ + public function addComplexType($type); +} |