| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204 |
- <?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-2012 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
- */
- require_once 'Zend/Soap/Server.php';
- /**
- * @see Zend_Soap_Client_Local
- */
- require_once 'Zend/Soap/Client/Local.php';
- /**
- * @see Zend_Soap_Client_Common
- */
- require_once 'Zend/Soap/Client/Common.php';
- /**
- * Zend_Soap_Client
- *
- * @category Zend
- * @package Zend_Soap
- * @subpackage Client
- * @copyright Copyright (c) 2005-2012 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;
- /**
- * 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')) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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;
- // Not used now
- // case 'connection_timeout':
- // $this->_connection_timeout = $value;
- // break;
- default:
- require_once 'Zend/Soap/Client/Exception.php';
- 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();
- 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'))) {
- 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))) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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)) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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)) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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))) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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))) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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)) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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
- */
- require_once "Zend/Soap/Client/Exception.php";
- 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;
- }
- /**
- * 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'])) {
- require_once 'Zend/Soap/Client/Exception.php';
- throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.');
- }
- if (!isset($options['uri'])) {
- require_once 'Zend/Soap/Client/Exception.php';
- throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.');
- }
- } else {
- if (isset($options['use'])) {
- require_once 'Zend/Soap/Client/Exception.php';
- throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.');
- }
- if (isset($options['style'])) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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) {
- require_once 'Zend/Soap/Client/Exception.php';
- 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;
- }
- }
|