File indexing completed on 2024-12-22 05:37:07
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Soap 0017 * @subpackage Client 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Soap_Server 0025 */ 0026 // require_once 'Zend/Soap/Server.php'; 0027 0028 /** 0029 * @see Zend_Soap_Client_Local 0030 */ 0031 // require_once 'Zend/Soap/Client/Local.php'; 0032 0033 /** 0034 * @see Zend_Soap_Client_Common 0035 */ 0036 // require_once 'Zend/Soap/Client/Common.php'; 0037 0038 /** 0039 * Zend_Soap_Client 0040 * 0041 * @category Zend 0042 * @package Zend_Soap 0043 * @subpackage Client 0044 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0045 * @license http://framework.zend.com/license/new-bsd New BSD License 0046 */ 0047 class Zend_Soap_Client 0048 { 0049 /** 0050 * Encoding 0051 * @var string 0052 */ 0053 protected $_encoding = 'UTF-8'; 0054 0055 /** 0056 * Array of SOAP type => PHP class pairings for handling return/incoming values 0057 * @var array 0058 */ 0059 protected $_classmap = null; 0060 0061 /** 0062 * Registered fault exceptions 0063 * @var array 0064 */ 0065 protected $_faultExceptions = array(); 0066 0067 /** 0068 * SOAP version to use; SOAP_1_2 by default, to allow processing of headers 0069 * @var int 0070 */ 0071 protected $_soapVersion = SOAP_1_2; 0072 0073 /** Set of other SoapClient options */ 0074 protected $_uri = null; 0075 protected $_location = null; 0076 protected $_style = null; 0077 protected $_use = null; 0078 protected $_login = null; 0079 protected $_password = null; 0080 protected $_proxy_host = null; 0081 protected $_proxy_port = null; 0082 protected $_proxy_login = null; 0083 protected $_proxy_password = null; 0084 protected $_local_cert = null; 0085 protected $_passphrase = null; 0086 protected $_compression = null; 0087 protected $_connection_timeout = null; 0088 protected $_stream_context = null; 0089 protected $_features = null; 0090 protected $_cache_wsdl = null; 0091 protected $_user_agent = null; 0092 protected $_exceptions = null; 0093 0094 /** 0095 * WSDL used to access server 0096 * It also defines Zend_Soap_Client working mode (WSDL vs non-WSDL) 0097 * 0098 * @var string 0099 */ 0100 protected $_wsdl = null; 0101 0102 /** 0103 * SoapClient object 0104 * 0105 * @var SoapClient 0106 */ 0107 protected $_soapClient; 0108 0109 /** 0110 * Last invoked method 0111 * 0112 * @var string 0113 */ 0114 protected $_lastMethod = ''; 0115 0116 /** 0117 * SOAP request headers. 0118 * 0119 * Array of SoapHeader objects 0120 * 0121 * @var array 0122 */ 0123 protected $_soapInputHeaders = array(); 0124 0125 /** 0126 * Permanent SOAP request headers (shared between requests). 0127 * 0128 * Array of SoapHeader objects 0129 * 0130 * @var array 0131 */ 0132 protected $_permanentSoapInputHeaders = array(); 0133 0134 /** 0135 * Output SOAP headers. 0136 * 0137 * Array of SoapHeader objects 0138 * 0139 * @var array 0140 */ 0141 protected $_soapOutputHeaders = array(); 0142 0143 /** 0144 * Constructor 0145 * 0146 * @param string $wsdl 0147 * @param array $options 0148 */ 0149 public function __construct($wsdl = null, $options = null) 0150 { 0151 if (!extension_loaded('soap')) { 0152 // require_once 'Zend/Soap/Client/Exception.php'; 0153 throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.'); 0154 } 0155 0156 if ($wsdl !== null) { 0157 $this->setWsdl($wsdl); 0158 } 0159 if ($options !== null) { 0160 $this->setOptions($options); 0161 } 0162 } 0163 0164 /** 0165 * Set wsdl 0166 * 0167 * @param string $wsdl 0168 * @return Zend_Soap_Client 0169 */ 0170 public function setWsdl($wsdl) 0171 { 0172 $this->_wsdl = $wsdl; 0173 $this->_soapClient = null; 0174 0175 return $this; 0176 } 0177 0178 /** 0179 * Get wsdl 0180 * 0181 * @return string 0182 */ 0183 public function getWsdl() 0184 { 0185 return $this->_wsdl; 0186 } 0187 0188 /** 0189 * Set Options 0190 * 0191 * Allows setting options as an associative array of option => value pairs. 0192 * 0193 * @param array|Zend_Config $options 0194 * @return Zend_Soap_Client 0195 * @throws Zend_SoapClient_Exception 0196 */ 0197 public function setOptions($options) 0198 { 0199 if($options instanceof Zend_Config) { 0200 $options = $options->toArray(); 0201 } 0202 0203 foreach ($options as $key => $value) { 0204 switch ($key) { 0205 case 'classmap': 0206 case 'classMap': 0207 $this->setClassmap($value); 0208 break; 0209 case 'encoding': 0210 $this->setEncoding($value); 0211 break; 0212 case 'soapVersion': 0213 case 'soap_version': 0214 $this->setSoapVersion($value); 0215 break; 0216 case 'wsdl': 0217 $this->setWsdl($value); 0218 break; 0219 case 'uri': 0220 $this->setUri($value); 0221 break; 0222 case 'location': 0223 $this->setLocation($value); 0224 break; 0225 case 'style': 0226 $this->setStyle($value); 0227 break; 0228 case 'use': 0229 $this->setEncodingMethod($value); 0230 break; 0231 case 'login': 0232 $this->setHttpLogin($value); 0233 break; 0234 case 'password': 0235 $this->setHttpPassword($value); 0236 break; 0237 case 'proxy_host': 0238 $this->setProxyHost($value); 0239 break; 0240 case 'proxy_port': 0241 $this->setProxyPort($value); 0242 break; 0243 case 'proxy_login': 0244 $this->setProxyLogin($value); 0245 break; 0246 case 'proxy_password': 0247 $this->setProxyPassword($value); 0248 break; 0249 case 'local_cert': 0250 $this->setHttpsCertificate($value); 0251 break; 0252 case 'passphrase': 0253 $this->setHttpsCertPassphrase($value); 0254 break; 0255 case 'compression': 0256 $this->setCompressionOptions($value); 0257 break; 0258 case 'stream_context': 0259 $this->setStreamContext($value); 0260 break; 0261 case 'features': 0262 $this->setSoapFeatures($value); 0263 break; 0264 case 'cache_wsdl': 0265 $this->setWsdlCache($value); 0266 break; 0267 case 'useragent': 0268 case 'userAgent': 0269 case 'user_agent': 0270 $this->setUserAgent($value); 0271 break; 0272 case 'exceptions': 0273 $this->setExceptions($value); 0274 break; 0275 0276 // Not used now 0277 // case 'connection_timeout': 0278 // $this->_connection_timeout = $value; 0279 // break; 0280 0281 default: 0282 // require_once 'Zend/Soap/Client/Exception.php'; 0283 throw new Zend_Soap_Client_Exception('Unknown SOAP client option'); 0284 break; 0285 } 0286 } 0287 0288 return $this; 0289 } 0290 0291 /** 0292 * Return array of options suitable for using with SoapClient constructor 0293 * 0294 * @return array 0295 */ 0296 public function getOptions() 0297 { 0298 $options = array(); 0299 0300 $options['classmap'] = $this->getClassmap(); 0301 $options['encoding'] = $this->getEncoding(); 0302 $options['soap_version'] = $this->getSoapVersion(); 0303 $options['wsdl'] = $this->getWsdl(); 0304 $options['uri'] = $this->getUri(); 0305 $options['location'] = $this->getLocation(); 0306 $options['style'] = $this->getStyle(); 0307 $options['use'] = $this->getEncodingMethod(); 0308 $options['login'] = $this->getHttpLogin(); 0309 $options['password'] = $this->getHttpPassword(); 0310 $options['proxy_host'] = $this->getProxyHost(); 0311 $options['proxy_port'] = $this->getProxyPort(); 0312 $options['proxy_login'] = $this->getProxyLogin(); 0313 $options['proxy_password'] = $this->getProxyPassword(); 0314 $options['local_cert'] = $this->getHttpsCertificate(); 0315 $options['passphrase'] = $this->getHttpsCertPassphrase(); 0316 $options['compression'] = $this->getCompressionOptions(); 0317 //$options['connection_timeout'] = $this->_connection_timeout; 0318 $options['stream_context'] = $this->getStreamContext(); 0319 $options['cache_wsdl'] = $this->getWsdlCache(); 0320 $options['features'] = $this->getSoapFeatures(); 0321 $options['user_agent'] = $this->getUserAgent(); 0322 $options['exceptions'] = $this->getExceptions(); 0323 0324 foreach ($options as $key => $value) { 0325 /* 0326 * ugly hack as I don't know if checking for '=== null' 0327 * breaks some other option 0328 */ 0329 if (in_array($key, array('user_agent', 'cache_wsdl', 'compression', 'exceptions'))) { 0330 if ($value === null) { 0331 unset($options[$key]); 0332 } 0333 } else { 0334 if ($value == null) { 0335 unset($options[$key]); 0336 } 0337 } 0338 } 0339 0340 return $options; 0341 } 0342 0343 /** 0344 * Set SOAP version 0345 * 0346 * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants 0347 * @return Zend_Soap_Client 0348 * @throws Zend_Soap_Client_Exception with invalid soap version argument 0349 */ 0350 public function setSoapVersion($version) 0351 { 0352 if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { 0353 // require_once 'Zend/Soap/Client/Exception.php'; 0354 throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); 0355 } 0356 $this->_soapVersion = $version; 0357 0358 $this->_soapClient = null; 0359 0360 return $this; 0361 } 0362 0363 /** 0364 * Get SOAP version 0365 * 0366 * @return int 0367 */ 0368 public function getSoapVersion() 0369 { 0370 return $this->_soapVersion; 0371 } 0372 0373 /** 0374 * Set classmap 0375 * 0376 * @param array $classmap 0377 * @return Zend_Soap_Client 0378 * @throws Zend_Soap_Client_Exception for any invalid class in the class map 0379 */ 0380 public function setClassmap(array $classmap) 0381 { 0382 foreach ($classmap as $type => $class) { 0383 if (!class_exists($class)) { 0384 // require_once 'Zend/Soap/Client/Exception.php'; 0385 throw new Zend_Soap_Client_Exception('Invalid class in class map'); 0386 } 0387 } 0388 0389 $this->_classmap = $classmap; 0390 0391 $this->_soapClient = null; 0392 0393 return $this; 0394 } 0395 0396 /** 0397 * Retrieve classmap 0398 * 0399 * @return mixed 0400 */ 0401 public function getClassmap() 0402 { 0403 return $this->_classmap; 0404 } 0405 0406 /** 0407 * Set encoding 0408 * 0409 * @param string $encoding 0410 * @return Zend_Soap_Client 0411 * @throws Zend_Soap_Client_Exception with invalid encoding argument 0412 */ 0413 public function setEncoding($encoding) 0414 { 0415 if (!is_string($encoding)) { 0416 // require_once 'Zend/Soap/Client/Exception.php'; 0417 throw new Zend_Soap_Client_Exception('Invalid encoding specified'); 0418 } 0419 0420 $this->_encoding = $encoding; 0421 0422 $this->_soapClient = null; 0423 0424 return $this; 0425 } 0426 0427 /** 0428 * Get encoding 0429 * 0430 * @return string 0431 */ 0432 public function getEncoding() 0433 { 0434 return $this->_encoding; 0435 } 0436 0437 /** 0438 * Check for valid URN 0439 * 0440 * @param string $urn 0441 * @return true 0442 * @throws Zend_Soap_Client_Exception on invalid URN 0443 */ 0444 public function validateUrn($urn) 0445 { 0446 $scheme = parse_url($urn, PHP_URL_SCHEME); 0447 if ($scheme === false || $scheme === null) { 0448 // require_once 'Zend/Soap/Client/Exception.php'; 0449 throw new Zend_Soap_Client_Exception('Invalid URN'); 0450 } 0451 0452 return true; 0453 0454 } 0455 0456 /** 0457 * Set URI 0458 * 0459 * URI in Web Service the target namespace 0460 * 0461 * @param string $uri 0462 * @return Zend_Soap_Client 0463 * @throws Zend_Soap_Client_Exception with invalid uri argument 0464 */ 0465 public function setUri($uri) 0466 { 0467 $this->validateUrn($uri); 0468 $this->_uri = $uri; 0469 0470 $this->_soapClient = null; 0471 0472 return $this; 0473 } 0474 0475 /** 0476 * Retrieve URI 0477 * 0478 * @return string 0479 */ 0480 public function getUri() 0481 { 0482 return $this->_uri; 0483 } 0484 0485 /** 0486 * Set Location 0487 * 0488 * URI in Web Service the target namespace 0489 * 0490 * @param string $location 0491 * @return Zend_Soap_Client 0492 * @throws Zend_Soap_Client_Exception with invalid uri argument 0493 */ 0494 public function setLocation($location) 0495 { 0496 $this->validateUrn($location); 0497 $this->_location = $location; 0498 0499 $this->_soapClient = null; 0500 0501 return $this; 0502 } 0503 0504 /** 0505 * Retrieve URI 0506 * 0507 * @return string 0508 */ 0509 public function getLocation() 0510 { 0511 return $this->_location; 0512 } 0513 0514 /** 0515 * Set request style 0516 * 0517 * @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants 0518 * @return Zend_Soap_Client 0519 * @throws Zend_Soap_Client_Exception with invalid style argument 0520 */ 0521 public function setStyle($style) 0522 { 0523 if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { 0524 // require_once 'Zend/Soap/Client/Exception.php'; 0525 throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); 0526 } 0527 0528 $this->_style = $style; 0529 0530 $this->_soapClient = null; 0531 0532 return $this; 0533 } 0534 0535 /** 0536 * Get request style 0537 * 0538 * @return int 0539 */ 0540 public function getStyle() 0541 { 0542 return $this->_style; 0543 } 0544 0545 /** 0546 * Set message encoding method 0547 * 0548 * @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants 0549 * @return Zend_Soap_Client 0550 * @throws Zend_Soap_Client_Exception with invalid message encoding method argument 0551 */ 0552 public function setEncodingMethod($use) 0553 { 0554 if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { 0555 // require_once 'Zend/Soap/Client/Exception.php'; 0556 throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); 0557 } 0558 0559 $this->_use = $use; 0560 0561 $this->_soapClient = null; 0562 0563 return $this; 0564 } 0565 0566 /** 0567 * Get message encoding method 0568 * 0569 * @return int 0570 */ 0571 public function getEncodingMethod() 0572 { 0573 return $this->_use; 0574 } 0575 0576 /** 0577 * Set HTTP login 0578 * 0579 * @param string $login 0580 * @return Zend_Soap_Client 0581 */ 0582 public function setHttpLogin($login) 0583 { 0584 $this->_login = $login; 0585 0586 $this->_soapClient = null; 0587 0588 return $this; 0589 } 0590 0591 /** 0592 * Retrieve HTTP Login 0593 * 0594 * @return string 0595 */ 0596 public function getHttpLogin() 0597 { 0598 return $this->_login; 0599 } 0600 0601 /** 0602 * Set HTTP password 0603 * 0604 * @param string $password 0605 * @return Zend_Soap_Client 0606 */ 0607 public function setHttpPassword($password) 0608 { 0609 $this->_password = $password; 0610 0611 $this->_soapClient = null; 0612 0613 return $this; 0614 } 0615 0616 /** 0617 * Retrieve HTTP Password 0618 * 0619 * @return string 0620 */ 0621 public function getHttpPassword() 0622 { 0623 return $this->_password; 0624 } 0625 0626 /** 0627 * Set proxy host 0628 * 0629 * @param string $proxyHost 0630 * @return Zend_Soap_Client 0631 */ 0632 public function setProxyHost($proxyHost) 0633 { 0634 $this->_proxy_host = $proxyHost; 0635 0636 $this->_soapClient = null; 0637 0638 return $this; 0639 } 0640 0641 /** 0642 * Retrieve proxy host 0643 * 0644 * @return string 0645 */ 0646 public function getProxyHost() 0647 { 0648 return $this->_proxy_host; 0649 } 0650 0651 /** 0652 * Set proxy port 0653 * 0654 * @param int $proxyPort 0655 * @return Zend_Soap_Client 0656 */ 0657 public function setProxyPort($proxyPort) 0658 { 0659 $this->_proxy_port = (int)$proxyPort; 0660 0661 $this->_soapClient = null; 0662 0663 return $this; 0664 } 0665 0666 /** 0667 * Retrieve proxy port 0668 * 0669 * @return int 0670 */ 0671 public function getProxyPort() 0672 { 0673 return $this->_proxy_port; 0674 } 0675 0676 /** 0677 * Set proxy login 0678 * 0679 * @param string $proxyLogin 0680 * @return Zend_Soap_Client 0681 */ 0682 public function setProxyLogin($proxyLogin) 0683 { 0684 $this->_proxy_login = $proxyLogin; 0685 0686 $this->_soapClient = null; 0687 0688 return $this; 0689 } 0690 0691 /** 0692 * Retrieve proxy login 0693 * 0694 * @return string 0695 */ 0696 public function getProxyLogin() 0697 { 0698 return $this->_proxy_login; 0699 } 0700 0701 /** 0702 * Set proxy password 0703 * 0704 * @param string $proxyLogin 0705 * @return Zend_Soap_Client 0706 */ 0707 public function setProxyPassword($proxyPassword) 0708 { 0709 $this->_proxy_password = $proxyPassword; 0710 0711 $this->_soapClient = null; 0712 0713 return $this; 0714 } 0715 0716 /** 0717 * Set HTTPS client certificate path 0718 * 0719 * @param string $localCert local certificate path 0720 * @return Zend_Soap_Client 0721 * @throws Zend_Soap_Client_Exception with invalid local certificate path argument 0722 */ 0723 public function setHttpsCertificate($localCert) 0724 { 0725 if (!is_readable($localCert)) { 0726 // require_once 'Zend/Soap/Client/Exception.php'; 0727 throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.'); 0728 } 0729 0730 $this->_local_cert = $localCert; 0731 0732 $this->_soapClient = null; 0733 0734 return $this; 0735 } 0736 0737 /** 0738 * Get HTTPS client certificate path 0739 * 0740 * @return string 0741 */ 0742 public function getHttpsCertificate() 0743 { 0744 return $this->_local_cert; 0745 } 0746 0747 /** 0748 * Set HTTPS client certificate passphrase 0749 * 0750 * @param string $passphrase 0751 * @return Zend_Soap_Client 0752 */ 0753 public function setHttpsCertPassphrase($passphrase) 0754 { 0755 $this->_passphrase = $passphrase; 0756 0757 $this->_soapClient = null; 0758 0759 return $this; 0760 } 0761 0762 /** 0763 * Get HTTPS client certificate passphrase 0764 * 0765 * @return string 0766 */ 0767 public function getHttpsCertPassphrase() 0768 { 0769 return $this->_passphrase; 0770 } 0771 0772 /** 0773 * Set compression options 0774 * 0775 * @param int|null $compressionOptions 0776 * @return Zend_Soap_Client 0777 */ 0778 public function setCompressionOptions($compressionOptions) 0779 { 0780 if ($compressionOptions === null) { 0781 $this->_compression = null; 0782 } else { 0783 $this->_compression = (int)$compressionOptions; 0784 } 0785 $this->_soapClient = null; 0786 return $this; 0787 } 0788 0789 /** 0790 * Get Compression options 0791 * 0792 * @return int 0793 */ 0794 public function getCompressionOptions() 0795 { 0796 return $this->_compression; 0797 } 0798 0799 /** 0800 * Retrieve proxy password 0801 * 0802 * @return string 0803 */ 0804 public function getProxyPassword() 0805 { 0806 return $this->_proxy_password; 0807 } 0808 0809 /** 0810 * Set Stream Context 0811 * 0812 * @return Zend_Soap_Client 0813 */ 0814 public function setStreamContext($context) 0815 { 0816 if(!is_resource($context) || get_resource_type($context) !== "stream-context") { 0817 /** 0818 * @see Zend_Soap_Client_Exception 0819 */ 0820 // require_once "Zend/Soap/Client/Exception.php"; 0821 throw new Zend_Soap_Client_Exception( 0822 "Invalid stream context resource given." 0823 ); 0824 } 0825 0826 $this->_stream_context = $context; 0827 return $this; 0828 } 0829 0830 /** 0831 * Get Stream Context 0832 * 0833 * @return resource 0834 */ 0835 public function getStreamContext() 0836 { 0837 return $this->_stream_context; 0838 } 0839 0840 /** 0841 * Set the SOAP Feature options. 0842 * 0843 * @param string|int $feature 0844 * @return Zend_Soap_Client 0845 */ 0846 public function setSoapFeatures($feature) 0847 { 0848 $this->_features = $feature; 0849 0850 $this->_soapClient = null; 0851 return $this; 0852 } 0853 0854 /** 0855 * Return current SOAP Features options 0856 * 0857 * @return int 0858 */ 0859 public function getSoapFeatures() 0860 { 0861 return $this->_features; 0862 } 0863 0864 /** 0865 * Set the SOAP Wsdl Caching Options 0866 * 0867 * @param string|int|boolean|null $caching 0868 * @return Zend_Soap_Client 0869 */ 0870 public function setWsdlCache($caching) 0871 { 0872 if ($caching === null) { 0873 $this->_cache_wsdl = null; 0874 } else { 0875 $this->_cache_wsdl = (int)$caching; 0876 } 0877 return $this; 0878 } 0879 0880 /** 0881 * Get current SOAP Wsdl Caching option 0882 * 0883 * @return int 0884 */ 0885 public function getWsdlCache() 0886 { 0887 return $this->_cache_wsdl; 0888 } 0889 0890 /** 0891 * Set the string to use in User-Agent header 0892 * 0893 * @param string|null $userAgent 0894 * @return Zend_Soap_Client 0895 */ 0896 public function setUserAgent($userAgent) 0897 { 0898 if ($userAgent === null) { 0899 $this->_user_agent = null; 0900 } else { 0901 $this->_user_agent = (string)$userAgent; 0902 } 0903 return $this; 0904 } 0905 0906 /** 0907 * Get current string to use in User-Agent header 0908 * 0909 * @return string|null 0910 */ 0911 public function getUserAgent() 0912 { 0913 return $this->_user_agent; 0914 } 0915 0916 /** 0917 * Set the exceptions option 0918 * 0919 * The exceptions option is a boolean value defining whether soap errors 0920 * throw exceptions. 0921 * 0922 * @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters 0923 * 0924 * @param bool $exceptions 0925 * @return $this 0926 */ 0927 public function setExceptions($exceptions) 0928 { 0929 $this->_exceptions = (bool) $exceptions; 0930 0931 return $this; 0932 } 0933 0934 /** 0935 * Get the exceptions option 0936 * 0937 * The exceptions option is a boolean value defining whether soap errors 0938 * throw exceptions. 0939 * 0940 * @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters 0941 * 0942 * @return bool|null 0943 */ 0944 public function getExceptions() 0945 { 0946 return $this->_exceptions; 0947 } 0948 0949 /** 0950 * Retrieve request XML 0951 * 0952 * @return string 0953 */ 0954 public function getLastRequest() 0955 { 0956 if ($this->_soapClient !== null) { 0957 return $this->_soapClient->__getLastRequest(); 0958 } 0959 0960 return ''; 0961 } 0962 0963 /** 0964 * Get response XML 0965 * 0966 * @return string 0967 */ 0968 public function getLastResponse() 0969 { 0970 if ($this->_soapClient !== null) { 0971 return $this->_soapClient->__getLastResponse(); 0972 } 0973 0974 return ''; 0975 } 0976 0977 /** 0978 * Retrieve request headers 0979 * 0980 * @return string 0981 */ 0982 public function getLastRequestHeaders() 0983 { 0984 if ($this->_soapClient !== null) { 0985 return $this->_soapClient->__getLastRequestHeaders(); 0986 } 0987 0988 return ''; 0989 } 0990 0991 /** 0992 * Retrieve response headers (as string) 0993 * 0994 * @return string 0995 */ 0996 public function getLastResponseHeaders() 0997 { 0998 if ($this->_soapClient !== null) { 0999 return $this->_soapClient->__getLastResponseHeaders(); 1000 } 1001 1002 return ''; 1003 } 1004 1005 /** 1006 * Retrieve last invoked method 1007 * 1008 * @return string 1009 */ 1010 public function getLastMethod() 1011 { 1012 return $this->_lastMethod; 1013 } 1014 1015 /** 1016 * Do request proxy method. 1017 * 1018 * May be overridden in subclasses 1019 * 1020 * @internal 1021 * @param Zend_Soap_Client_Common $client 1022 * @param string $request 1023 * @param string $location 1024 * @param string $action 1025 * @param int $version 1026 * @param int $one_way 1027 * @return mixed 1028 */ 1029 public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) 1030 { 1031 // Perform request as is 1032 if ($one_way == null) { 1033 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); 1034 } else { 1035 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); 1036 } 1037 } 1038 1039 /** 1040 * Initialize SOAP Client object 1041 * 1042 * @throws Zend_Soap_Client_Exception 1043 */ 1044 protected function _initSoapClientObject() 1045 { 1046 $wsdl = $this->getWsdl(); 1047 $options = array_merge($this->getOptions(), array('trace' => true)); 1048 1049 if ($wsdl == null) { 1050 if (!isset($options['location'])) { 1051 // require_once 'Zend/Soap/Client/Exception.php'; 1052 throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); 1053 } 1054 if (!isset($options['uri'])) { 1055 // require_once 'Zend/Soap/Client/Exception.php'; 1056 throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); 1057 } 1058 } else { 1059 if (isset($options['use'])) { 1060 // require_once 'Zend/Soap/Client/Exception.php'; 1061 throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); 1062 } 1063 if (isset($options['style'])) { 1064 // require_once 'Zend/Soap/Client/Exception.php'; 1065 throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); 1066 } 1067 } 1068 unset($options['wsdl']); 1069 1070 $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options); 1071 } 1072 1073 1074 /** 1075 * Perform arguments pre-processing 1076 * 1077 * My be overridden in descendant classes 1078 * 1079 * @param array $arguments 1080 */ 1081 protected function _preProcessArguments($arguments) 1082 { 1083 // Do nothing 1084 return $arguments; 1085 } 1086 1087 /** 1088 * Perform result pre-processing 1089 * 1090 * My be overridden in descendant classes 1091 * 1092 * @param array $arguments 1093 */ 1094 protected function _preProcessResult($result) 1095 { 1096 // Do nothing 1097 return $result; 1098 } 1099 1100 /** 1101 * Add SOAP input header 1102 * 1103 * @param SoapHeader $header 1104 * @param boolean $permanent 1105 * @return Zend_Soap_Client 1106 */ 1107 public function addSoapInputHeader(SoapHeader $header, $permanent = false) 1108 { 1109 if ($permanent) { 1110 $this->_permanentSoapInputHeaders[] = $header; 1111 } else { 1112 $this->_soapInputHeaders[] = $header; 1113 } 1114 1115 return $this; 1116 } 1117 1118 /** 1119 * Reset SOAP input headers 1120 * 1121 * @return Zend_Soap_Client 1122 */ 1123 public function resetSoapInputHeaders() 1124 { 1125 $this->_permanentSoapInputHeaders = array(); 1126 $this->_soapInputHeaders = array(); 1127 1128 return $this; 1129 } 1130 1131 /** 1132 * Get last SOAP output headers 1133 * 1134 * @return array 1135 */ 1136 public function getLastSoapOutputHeaderObjects() 1137 { 1138 return $this->_soapOutputHeaders; 1139 } 1140 1141 /** 1142 * Perform a SOAP call 1143 * 1144 * @param string $name 1145 * @param array $arguments 1146 * @return mixed 1147 */ 1148 public function __call($name, $arguments) 1149 { 1150 $soapClient = $this->getSoapClient(); 1151 1152 $this->_lastMethod = $name; 1153 1154 $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); 1155 $result = $soapClient->__soapCall($name, 1156 $this->_preProcessArguments($arguments), 1157 null, /* Options are already set to the SOAP client object */ 1158 (count($soapHeaders) > 0)? $soapHeaders : null, 1159 $this->_soapOutputHeaders); 1160 1161 // Reset non-permanent input headers 1162 $this->_soapInputHeaders = array(); 1163 1164 return $this->_preProcessResult($result); 1165 } 1166 1167 1168 /** 1169 * Return a list of available functions 1170 * 1171 * @return array 1172 * @throws Zend_Soap_Client_Exception 1173 */ 1174 public function getFunctions() 1175 { 1176 if ($this->getWsdl() == null) { 1177 // require_once 'Zend/Soap/Client/Exception.php'; 1178 throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); 1179 } 1180 1181 $soapClient = $this->getSoapClient(); 1182 return $soapClient->__getFunctions(); 1183 } 1184 1185 1186 /** 1187 * Get used types. 1188 * 1189 * @return array 1190 */ 1191 1192 /** 1193 * Return a list of SOAP types 1194 * 1195 * @return array 1196 * @throws Zend_Soap_Client_Exception 1197 */ 1198 public function getTypes() 1199 { 1200 if ($this->getWsdl() == null) { 1201 // require_once 'Zend/Soap/Client/Exception.php'; 1202 throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); 1203 } 1204 1205 $soapClient = $this->getSoapClient(); 1206 1207 return $soapClient->__getTypes(); 1208 } 1209 1210 /** 1211 * @param SoapClient $soapClient 1212 * @return Zend_Soap_Client 1213 */ 1214 public function setSoapClient(SoapClient $soapClient) 1215 { 1216 $this->_soapClient = $soapClient; 1217 return $this; 1218 } 1219 1220 /** 1221 * @return SoapClient 1222 */ 1223 public function getSoapClient() 1224 { 1225 if ($this->_soapClient == null) { 1226 $this->_initSoapClientObject(); 1227 } 1228 return $this->_soapClient; 1229 } 1230 1231 /** 1232 * @param string $name 1233 * @param string $value 1234 * @return Zend_Soap_Client 1235 */ 1236 public function setCookie($cookieName, $cookieValue=null) 1237 { 1238 $soapClient = $this->getSoapClient(); 1239 $soapClient->__setCookie($cookieName, $cookieValue); 1240 return $this; 1241 } 1242 }