open/home/xh000520/public_html/library/Zend/Soap/Client.php
1
<?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_Soap
17 * @subpackage Client
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Client.php 24593 2012-01-05 20:35:02Z matthew $
21 */
22
23 /**
24 * @see Zend_Soap_Server
25 */
26 require_once 'Zend/Soap/Server.php';
27
28 /**
29 * @see Zend_Soap_Client_Local
30 */
31 require_once 'Zend/Soap/Client/Local.php';
32
33 /**
34 * @see Zend_Soap_Client_Common
35 */
36 require_once 'Zend/Soap/Client/Common.php';
37
38 /**
39 * Zend_Soap_Client
40 *
41 * @category Zend
42 * @package Zend_Soap
43 * @subpackage Client
44 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
45 * @license http://framework.zend.com/license/new-bsd New BSD License
46 */
47 class Zend_Soap_Client
48 {
49 /**
50 * Encoding
51 * @var string
52 */
53 protected $_encoding = 'UTF-8';
54
55 /**
56 * Array of SOAP type => PHP class pairings for handling return/incoming values
57 * @var array
58 */
59 protected $_classmap = null;
60
61 /**
62 * Registered fault exceptions
63 * @var array
64 */
65 protected $_faultExceptions = array();
66
67 /**
68 * SOAP version to use; SOAP_1_2 by default, to allow processing of headers
69 * @var int
70 */
71 protected $_soapVersion = SOAP_1_2;
72
73 /** Set of other SoapClient options */
74 protected $_uri = null;
75 protected $_location = null;
76 protected $_style = null;
77 protected $_use = null;
78 protected $_login = null;
79 protected $_password = null;
80 protected $_proxy_host = null;
81 protected $_proxy_port = null;
82 protected $_proxy_login = null;
83 protected $_proxy_password = null;
84 protected $_local_cert = null;
85 protected $_passphrase = null;
86 protected $_compression = null;
87 protected $_connection_timeout = null;
88 protected $_stream_context = null;
89 protected $_features = null;
90 protected $_cache_wsdl = null;
91 protected $_user_agent = null;
92
93 /**
94 * WSDL used to access server
95 * It also defines Zend_Soap_Client working mode (WSDL vs non-WSDL)
96 *
97 * @var string
98 */
99 protected $_wsdl = null;
100
101 /**
102 * SoapClient object
103 *
104 * @var SoapClient
105 */
106 protected $_soapClient;
107
108 /**
109 * Last invoked method
110 *
111 * @var string
112 */
113 protected $_lastMethod = '';
114
115 /**
116 * SOAP request headers.
117 *
118 * Array of SoapHeader objects
119 *
120 * @var array
121 */
122 protected $_soapInputHeaders = array();
123
124 /**
125 * Permanent SOAP request headers (shared between requests).
126 *
127 * Array of SoapHeader objects
128 *
129 * @var array
130 */
131 protected $_permanentSoapInputHeaders = array();
132
133 /**
134 * Output SOAP headers.
135 *
136 * Array of SoapHeader objects
137 *
138 * @var array
139 */
140 protected $_soapOutputHeaders = array();
141
142 /**
143 * Constructor
144 *
145 * @param string $wsdl
146 * @param array $options
147 */
148 public function __construct($wsdl = null, $options = null)
149 {
150 if (!extension_loaded('soap')) {
151 require_once 'Zend/Soap/Client/Exception.php';
152 throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.');
153 }
154
155 if ($wsdl !== null) {
156 $this->setWsdl($wsdl);
157 }
158 if ($options !== null) {
159 $this->setOptions($options);
160 }
161 }
162
163 /**
164 * Set wsdl
165 *
166 * @param string $wsdl
167 * @return Zend_Soap_Client
168 */
169 public function setWsdl($wsdl)
170 {
171 $this->_wsdl = $wsdl;
172 $this->_soapClient = null;
173
174 return $this;
175 }
176
177 /**
178 * Get wsdl
179 *
180 * @return string
181 */
182 public function getWsdl()
183 {
184 return $this->_wsdl;
185 }
186
187 /**
188 * Set Options
189 *
190 * Allows setting options as an associative array of option => value pairs.
191 *
192 * @param array|Zend_Config $options
193 * @return Zend_Soap_Client
194 * @throws Zend_SoapClient_Exception
195 */
196 public function setOptions($options)
197 {
198 if($options instanceof Zend_Config) {
199 $options = $options->toArray();
200 }
201
202 foreach ($options as $key => $value) {
203 switch ($key) {
204 case 'classmap':
205 case 'classMap':
206 $this->setClassmap($value);
207 break;
208 case 'encoding':
209 $this->setEncoding($value);
210 break;
211 case 'soapVersion':
212 case 'soap_version':
213 $this->setSoapVersion($value);
214 break;
215 case 'wsdl':
216 $this->setWsdl($value);
217 break;
218 case 'uri':
219 $this->setUri($value);
220 break;
221 case 'location':
222 $this->setLocation($value);
223 break;
224 case 'style':
225 $this->setStyle($value);
226 break;
227 case 'use':
228 $this->setEncodingMethod($value);
229 break;
230 case 'login':
231 $this->setHttpLogin($value);
232 break;
233 case 'password':
234 $this->setHttpPassword($value);
235 break;
236 case 'proxy_host':
237 $this->setProxyHost($value);
238 break;
239 case 'proxy_port':
240 $this->setProxyPort($value);
241 break;
242 case 'proxy_login':
243 $this->setProxyLogin($value);
244 break;
245 case 'proxy_password':
246 $this->setProxyPassword($value);
247 break;
248 case 'local_cert':
249 $this->setHttpsCertificate($value);
250 break;
251 case 'passphrase':
252 $this->setHttpsCertPassphrase($value);
253 break;
254 case 'compression':
255 $this->setCompressionOptions($value);
256 break;
257 case 'stream_context':
258 $this->setStreamContext($value);
259 break;
260 case 'features':
261 $this->setSoapFeatures($value);
262 break;
263 case 'cache_wsdl':
264 $this->setWsdlCache($value);
265 break;
266 case 'useragent':
267 case 'userAgent':
268 case 'user_agent':
269 $this->setUserAgent($value);
270 break;
271
272 // Not used now
273 // case 'connection_timeout':
274 // $this->_connection_timeout = $value;
275 // break;
276
277 default:
278 require_once 'Zend/Soap/Client/Exception.php';
279 throw new Zend_Soap_Client_Exception('Unknown SOAP client option');
280 break;
281 }
282 }
283
284 return $this;
285 }
286
287 /**
288 * Return array of options suitable for using with SoapClient constructor
289 *
290 * @return array
291 */
292 public function getOptions()
293 {
294 $options = array();
295
296 $options['classmap'] = $this->getClassmap();
297 $options['encoding'] = $this->getEncoding();
298 $options['soap_version'] = $this->getSoapVersion();
299 $options['wsdl'] = $this->getWsdl();
300 $options['uri'] = $this->getUri();
301 $options['location'] = $this->getLocation();
302 $options['style'] = $this->getStyle();
303 $options['use'] = $this->getEncodingMethod();
304 $options['login'] = $this->getHttpLogin();
305 $options['password'] = $this->getHttpPassword();
306 $options['proxy_host'] = $this->getProxyHost();
307 $options['proxy_port'] = $this->getProxyPort();
308 $options['proxy_login'] = $this->getProxyLogin();
309 $options['proxy_password'] = $this->getProxyPassword();
310 $options['local_cert'] = $this->getHttpsCertificate();
311 $options['passphrase'] = $this->getHttpsCertPassphrase();
312 $options['compression'] = $this->getCompressionOptions();
313 //$options['connection_timeout'] = $this->_connection_timeout;
314 $options['stream_context'] = $this->getStreamContext();
315 $options['cache_wsdl'] = $this->getWsdlCache();
316 $options['features'] = $this->getSoapFeatures();
317 $options['user_agent'] = $this->getUserAgent();
318
319 foreach ($options as $key => $value) {
320 /*
321 * ugly hack as I don't know if checking for '=== null'
322 * breaks some other option
323 */
324 if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) {
325 if ($value === null) {
326 unset($options[$key]);
327 }
328 } else {
329 if ($value == null) {
330 unset($options[$key]);
331 }
332 }
333 }
334
335 return $options;
336 }
337
338 /**
339 * Set SOAP version
340 *
341 * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants
342 * @return Zend_Soap_Client
343 * @throws Zend_Soap_Client_Exception with invalid soap version argument
344 */
345 public function setSoapVersion($version)
346 {
347 if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) {
348 require_once 'Zend/Soap/Client/Exception.php';
349 throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.');
350 }
351 $this->_soapVersion = $version;
352
353 $this->_soapClient = null;
354
355 return $this;
356 }
357
358 /**
359 * Get SOAP version
360 *
361 * @return int
362 */
363 public function getSoapVersion()
364 {
365 return $this->_soapVersion;
366 }
367
368 /**
369 * Set classmap
370 *
371 * @param array $classmap
372 * @return Zend_Soap_Client
373 * @throws Zend_Soap_Client_Exception for any invalid class in the class map
374 */
375 public function setClassmap(array $classmap)
376 {
377 foreach ($classmap as $type => $class) {
378 if (!class_exists($class)) {
379 require_once 'Zend/Soap/Client/Exception.php';
380 throw new Zend_Soap_Client_Exception('Invalid class in class map');
381 }
382 }
383
384 $this->_classmap = $classmap;
385
386 $this->_soapClient = null;
387
388 return $this;
389 }
390
391 /**
392 * Retrieve classmap
393 *
394 * @return mixed
395 */
396 public function getClassmap()
397 {
398 return $this->_classmap;
399 }
400
401 /**
402 * Set encoding
403 *
404 * @param string $encoding
405 * @return Zend_Soap_Client
406 * @throws Zend_Soap_Client_Exception with invalid encoding argument
407 */
408 public function setEncoding($encoding)
409 {
410 if (!is_string($encoding)) {
411 require_once 'Zend/Soap/Client/Exception.php';
412 throw new Zend_Soap_Client_Exception('Invalid encoding specified');
413 }
414
415 $this->_encoding = $encoding;
416
417 $this->_soapClient = null;
418
419 return $this;
420 }
421
422 /**
423 * Get encoding
424 *
425 * @return string
426 */
427 public function getEncoding()
428 {
429 return $this->_encoding;
430 }
431
432 /**
433 * Check for valid URN
434 *
435 * @param string $urn
436 * @return true
437 * @throws Zend_Soap_Client_Exception on invalid URN
438 */
439 public function validateUrn($urn)
440 {
441 $scheme = parse_url($urn, PHP_URL_SCHEME);
442 if ($scheme === false || $scheme === null) {
443 require_once 'Zend/Soap/Client/Exception.php';
444 throw new Zend_Soap_Client_Exception('Invalid URN');
445 }
446
447 return true;
448
449 }
450
451 /**
452 * Set URI
453 *
454 * URI in Web Service the target namespace
455 *
456 * @param string $uri
457 * @return Zend_Soap_Client
458 * @throws Zend_Soap_Client_Exception with invalid uri argument
459 */
460 public function setUri($uri)
461 {
462 $this->validateUrn($uri);
463 $this->_uri = $uri;
464
465 $this->_soapClient = null;
466
467 return $this;
468 }
469
470 /**
471 * Retrieve URI
472 *
473 * @return string
474 */
475 public function getUri()
476 {
477 return $this->_uri;
478 }
479
480 /**
481 * Set Location
482 *
483 * URI in Web Service the target namespace
484 *
485 * @param string $location
486 * @return Zend_Soap_Client
487 * @throws Zend_Soap_Client_Exception with invalid uri argument
488 */
489 public function setLocation($location)
490 {
491 $this->validateUrn($location);
492 $this->_location = $location;
493
494 $this->_soapClient = null;
495
496 return $this;
497 }
498
499 /**
500 * Retrieve URI
501 *
502 * @return string
503 */
504 public function getLocation()
505 {
506 return $this->_location;
507 }
508
509 /**
510 * Set request style
511 *
512 * @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants
513 * @return Zend_Soap_Client
514 * @throws Zend_Soap_Client_Exception with invalid style argument
515 */
516 public function setStyle($style)
517 {
518 if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) {
519 require_once 'Zend/Soap/Client/Exception.php';
520 throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.');
521 }
522
523 $this->_style = $style;
524
525 $this->_soapClient = null;
526
527 return $this;
528 }
529
530 /**
531 * Get request style
532 *
533 * @return int
534 */
535 public function getStyle()
536 {
537 return $this->_style;
538 }
539
540 /**
541 * Set message encoding method
542 *
543 * @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants
544 * @return Zend_Soap_Client
545 * @throws Zend_Soap_Client_Exception with invalid message encoding method argument
546 */
547 public function setEncodingMethod($use)
548 {
549 if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) {
550 require_once 'Zend/Soap/Client/Exception.php';
551 throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.');
552 }
553
554 $this->_use = $use;
555
556 $this->_soapClient = null;
557
558 return $this;
559 }
560
561 /**
562 * Get message encoding method
563 *
564 * @return int
565 */
566 public function getEncodingMethod()
567 {
568 return $this->_use;
569 }
570
571 /**
572 * Set HTTP login
573 *
574 * @param string $login
575 * @return Zend_Soap_Client
576 */
577 public function setHttpLogin($login)
578 {
579 $this->_login = $login;
580
581 $this->_soapClient = null;
582
583 return $this;
584 }
585
586 /**
587 * Retrieve HTTP Login
588 *
589 * @return string
590 */
591 public function getHttpLogin()
592 {
593 return $this->_login;
594 }
595
596 /**
597 * Set HTTP password
598 *
599 * @param string $password
600 * @return Zend_Soap_Client
601 */
602 public function setHttpPassword($password)
603 {
604 $this->_password = $password;
605
606 $this->_soapClient = null;
607
608 return $this;
609 }
610
611 /**
612 * Retrieve HTTP Password
613 *
614 * @return string
615 */
616 public function getHttpPassword()
617 {
618 return $this->_password;
619 }
620
621 /**
622 * Set proxy host
623 *
624 * @param string $proxyHost
625 * @return Zend_Soap_Client
626 */
627 public function setProxyHost($proxyHost)
628 {
629 $this->_proxy_host = $proxyHost;
630
631 $this->_soapClient = null;
632
633 return $this;
634 }
635
636 /**
637 * Retrieve proxy host
638 *
639 * @return string
640 */
641 public function getProxyHost()
642 {
643 return $this->_proxy_host;
644 }
645
646 /**
647 * Set proxy port
648 *
649 * @param int $proxyPort
650 * @return Zend_Soap_Client
651 */
652 public function setProxyPort($proxyPort)
653 {
654 $this->_proxy_port = (int)$proxyPort;
655
656 $this->_soapClient = null;
657
658 return $this;
659 }
660
661 /**
662 * Retrieve proxy port
663 *
664 * @return int
665 */
666 public function getProxyPort()
667 {
668 return $this->_proxy_port;
669 }
670
671 /**
672 * Set proxy login
673 *
674 * @param string $proxyLogin
675 * @return Zend_Soap_Client
676 */
677 public function setProxyLogin($proxyLogin)
678 {
679 $this->_proxy_login = $proxyLogin;
680
681 $this->_soapClient = null;
682
683 return $this;
684 }
685
686 /**
687 * Retrieve proxy login
688 *
689 * @return string
690 */
691 public function getProxyLogin()
692 {
693 return $this->_proxy_login;
694 }
695
696 /**
697 * Set proxy password
698 *
699 * @param string $proxyLogin
700 * @return Zend_Soap_Client
701 */
702 public function setProxyPassword($proxyPassword)
703 {
704 $this->_proxy_password = $proxyPassword;
705
706 $this->_soapClient = null;
707
708 return $this;
709 }
710
711 /**
712 * Set HTTPS client certificate path
713 *
714 * @param string $localCert local certificate path
715 * @return Zend_Soap_Client
716 * @throws Zend_Soap_Client_Exception with invalid local certificate path argument
717 */
718 public function setHttpsCertificate($localCert)
719 {
720 if (!is_readable($localCert)) {
721 require_once 'Zend/Soap/Client/Exception.php';
722 throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.');
723 }
724
725 $this->_local_cert = $localCert;
726
727 $this->_soapClient = null;
728
729 return $this;
730 }
731
732 /**
733 * Get HTTPS client certificate path
734 *
735 * @return string
736 */
737 public function getHttpsCertificate()
738 {
739 return $this->_local_cert;
740 }
741
742 /**
743 * Set HTTPS client certificate passphrase
744 *
745 * @param string $passphrase
746 * @return Zend_Soap_Client
747 */
748 public function setHttpsCertPassphrase($passphrase)
749 {
750 $this->_passphrase = $passphrase;
751
752 $this->_soapClient = null;
753
754 return $this;
755 }
756
757 /**
758 * Get HTTPS client certificate passphrase
759 *
760 * @return string
761 */
762 public function getHttpsCertPassphrase()
763 {
764 return $this->_passphrase;
765 }
766
767 /**
768 * Set compression options
769 *
770 * @param int|null $compressionOptions
771 * @return Zend_Soap_Client
772 */
773 public function setCompressionOptions($compressionOptions)
774 {
775 if ($compressionOptions === null) {
776 $this->_compression = null;
777 } else {
778 $this->_compression = (int)$compressionOptions;
779 }
780 $this->_soapClient = null;
781 return $this;
782 }
783
784 /**
785 * Get Compression options
786 *
787 * @return int
788 */
789 public function getCompressionOptions()
790 {
791 return $this->_compression;
792 }
793
794 /**
795 * Retrieve proxy password
796 *
797 * @return string
798 */
799 public function getProxyPassword()
800 {
801 return $this->_proxy_password;
802 }
803
804 /**
805 * Set Stream Context
806 *
807 * @return Zend_Soap_Client
808 */
809 public function setStreamContext($context)
810 {
811 if(!is_resource($context) || get_resource_type($context) !== "stream-context") {
812 /**
813 * @see Zend_Soap_Client_Exception
814 */
815 require_once "Zend/Soap/Client/Exception.php";
816 throw new Zend_Soap_Client_Exception(
817 "Invalid stream context resource given."
818 );
819 }
820
821 $this->_stream_context = $context;
822 return $this;
823 }
824
825 /**
826 * Get Stream Context
827 *
828 * @return resource
829 */
830 public function getStreamContext()
831 {
832 return $this->_stream_context;
833 }
834
835 /**
836 * Set the SOAP Feature options.
837 *
838 * @param string|int $feature
839 * @return Zend_Soap_Client
840 */
841 public function setSoapFeatures($feature)
842 {
843 $this->_features = $feature;
844
845 $this->_soapClient = null;
846 return $this;
847 }
848
849 /**
850 * Return current SOAP Features options
851 *
852 * @return int
853 */
854 public function getSoapFeatures()
855 {
856 return $this->_features;
857 }
858
859 /**
860 * Set the SOAP Wsdl Caching Options
861 *
862 * @param string|int|boolean|null $caching
863 * @return Zend_Soap_Client
864 */
865 public function setWsdlCache($caching)
866 {
867 if ($caching === null) {
868 $this->_cache_wsdl = null;
869 } else {
870 $this->_cache_wsdl = (int)$caching;
871 }
872 return $this;
873 }
874
875 /**
876 * Get current SOAP Wsdl Caching option
877 *
878 * @return int
879 */
880 public function getWsdlCache()
881 {
882 return $this->_cache_wsdl;
883 }
884
885 /**
886 * Set the string to use in User-Agent header
887 *
888 * @param string|null $userAgent
889 * @return Zend_Soap_Client
890 */
891 public function setUserAgent($userAgent)
892 {
893 if ($userAgent === null) {
894 $this->_user_agent = null;
895 } else {
896 $this->_user_agent = (string)$userAgent;
897 }
898 return $this;
899 }
900
901 /**
902 * Get current string to use in User-Agent header
903 *
904 * @return string|null
905 */
906 public function getUserAgent()
907 {
908 return $this->_user_agent;
909 }
910
911 /**
912 * Retrieve request XML
913 *
914 * @return string
915 */
916 public function getLastRequest()
917 {
918 if ($this->_soapClient !== null) {
919 return $this->_soapClient->__getLastRequest();
920 }
921
922 return '';
923 }
924
925 /**
926 * Get response XML
927 *
928 * @return string
929 */
930 public function getLastResponse()
931 {
932 if ($this->_soapClient !== null) {
933 return $this->_soapClient->__getLastResponse();
934 }
935
936 return '';
937 }
938
939 /**
940 * Retrieve request headers
941 *
942 * @return string
943 */
944 public function getLastRequestHeaders()
945 {
946 if ($this->_soapClient !== null) {
947 return $this->_soapClient->__getLastRequestHeaders();
948 }
949
950 return '';
951 }
952
953 /**
954 * Retrieve response headers (as string)
955 *
956 * @return string
957 */
958 public function getLastResponseHeaders()
959 {
960 if ($this->_soapClient !== null) {
961 return $this->_soapClient->__getLastResponseHeaders();
962 }
963
964 return '';
965 }
966
967 /**
968 * Retrieve last invoked method
969 *
970 * @return string
971 */
972 public function getLastMethod()
973 {
974 return $this->_lastMethod;
975 }
976
977 /**
978 * Do request proxy method.
979 *
980 * May be overridden in subclasses
981 *
982 * @internal
983 * @param Zend_Soap_Client_Common $client
984 * @param string $request
985 * @param string $location
986 * @param string $action
987 * @param int $version
988 * @param int $one_way
989 * @return mixed
990 */
991 public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null)
992 {
993 // Perform request as is
994 if ($one_way == null) {
995 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version);
996 } else {
997 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way);
998 }
999 }
1000
1001 /**
1002 * Initialize SOAP Client object
1003 *
1004 * @throws Zend_Soap_Client_Exception
1005 */
1006 protected function _initSoapClientObject()
1007 {
1008 $wsdl = $this->getWsdl();
1009 $options = array_merge($this->getOptions(), array('trace' => true));
1010
1011 if ($wsdl == null) {
1012 if (!isset($options['location'])) {
1013 require_once 'Zend/Soap/Client/Exception.php';
1014 throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.');
1015 }
1016 if (!isset($options['uri'])) {
1017 require_once 'Zend/Soap/Client/Exception.php';
1018 throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.');
1019 }
1020 } else {
1021 if (isset($options['use'])) {
1022 require_once 'Zend/Soap/Client/Exception.php';
1023 throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.');
1024 }
1025 if (isset($options['style'])) {
1026 require_once 'Zend/Soap/Client/Exception.php';
1027 throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.');
1028 }
1029 }
1030 unset($options['wsdl']);
1031
1032 $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options);
1033 }
1034
1035
1036 /**
1037 * Perform arguments pre-processing
1038 *
1039 * My be overridden in descendant classes
1040 *
1041 * @param array $arguments
1042 */
1043 protected function _preProcessArguments($arguments)
1044 {
1045 // Do nothing
1046 return $arguments;
1047 }
1048
1049 /**
1050 * Perform result pre-processing
1051 *
1052 * My be overridden in descendant classes
1053 *
1054 * @param array $arguments
1055 */
1056 protected function _preProcessResult($result)
1057 {
1058 // Do nothing
1059 return $result;
1060 }
1061
1062 /**
1063 * Add SOAP input header
1064 *
1065 * @param SoapHeader $header
1066 * @param boolean $permanent
1067 * @return Zend_Soap_Client
1068 */
1069 public function addSoapInputHeader(SoapHeader $header, $permanent = false)
1070 {
1071 if ($permanent) {
1072 $this->_permanentSoapInputHeaders[] = $header;
1073 } else {
1074 $this->_soapInputHeaders[] = $header;
1075 }
1076
1077 return $this;
1078 }
1079
1080 /**
1081 * Reset SOAP input headers
1082 *
1083 * @return Zend_Soap_Client
1084 */
1085 public function resetSoapInputHeaders()
1086 {
1087 $this->_permanentSoapInputHeaders = array();
1088 $this->_soapInputHeaders = array();
1089
1090 return $this;
1091 }
1092
1093 /**
1094 * Get last SOAP output headers
1095 *
1096 * @return array
1097 */
1098 public function getLastSoapOutputHeaderObjects()
1099 {
1100 return $this->_soapOutputHeaders;
1101 }
1102
1103 /**
1104 * Perform a SOAP call
1105 *
1106 * @param string $name
1107 * @param array $arguments
1108 * @return mixed
1109 */
1110 public function __call($name, $arguments)
1111 {
1112 $soapClient = $this->getSoapClient();
1113
1114 $this->_lastMethod = $name;
1115
1116 $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders);
1117 $result = $soapClient->__soapCall($name,
1118 $this->_preProcessArguments($arguments),
1119 null, /* Options are already set to the SOAP client object */
1120 (count($soapHeaders) > 0)? $soapHeaders : null,
1121 $this->_soapOutputHeaders);
1122
1123 // Reset non-permanent input headers
1124 $this->_soapInputHeaders = array();
1125
1126 return $this->_preProcessResult($result);
1127 }
1128
1129
1130 /**
1131 * Return a list of available functions
1132 *
1133 * @return array
1134 * @throws Zend_Soap_Client_Exception
1135 */
1136 public function getFunctions()
1137 {
1138 if ($this->getWsdl() == null) {
1139 require_once 'Zend/Soap/Client/Exception.php';
1140 throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.');
1141 }
1142
1143 $soapClient = $this->getSoapClient();
1144 return $soapClient->__getFunctions();
1145 }
1146
1147
1148 /**
1149 * Get used types.
1150 *
1151 * @return array
1152 */
1153
1154 /**
1155 * Return a list of SOAP types
1156 *
1157 * @return array
1158 * @throws Zend_Soap_Client_Exception
1159 */
1160 public function getTypes()
1161 {
1162 if ($this->getWsdl() == null) {
1163 require_once 'Zend/Soap/Client/Exception.php';
1164 throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.');
1165 }
1166
1167 $soapClient = $this->getSoapClient();
1168
1169 return $soapClient->__getTypes();
1170 }
1171
1172 /**
1173 * @param SoapClient $soapClient
1174 * @return Zend_Soap_Client
1175 */
1176 public function setSoapClient(SoapClient $soapClient)
1177 {
1178 $this->_soapClient = $soapClient;
1179 return $this;
1180 }
1181
1182 /**
1183 * @return SoapClient
1184 */
1185 public function getSoapClient()
1186 {
1187 if ($this->_soapClient == null) {
1188 $this->_initSoapClientObject();
1189 }
1190 return $this->_soapClient;
1191 }
1192
1193 /**
1194 * @param string $name
1195 * @param string $value
1196 * @return Zend_Soap_Client
1197 */
1198 public function setCookie($cookieName, $cookieValue=null)
1199 {
1200 $soapClient = $this->getSoapClient();
1201 $soapClient->__setCookie($cookieName, $cookieValue);
1202 return $this;
1203 }
1204 }
1205