123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242 |
- <?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
- */
- #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-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')) {
- #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;
- case 'exceptions':
- $this->setExceptions($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();
- $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))) {
- #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;
- }
- /**
- * 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'])) {
- #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;
- }
- }
|