[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Soap 17 * @subpackage Client 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 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-2010 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 ($key == 'user_agent') { 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 $compressionOptions 771 * @return Zend_Soap_Client 772 */ 773 public function setCompressionOptions($compressionOptions) 774 { 775 $this->_compression = $compressionOptions; 776 777 $this->_soapClient = null; 778 779 return $this; 780 } 781 782 /** 783 * Get Compression options 784 * 785 * @return int 786 */ 787 public function getCompressionOptions() 788 { 789 return $this->_compression; 790 } 791 792 /** 793 * Retrieve proxy password 794 * 795 * @return string 796 */ 797 public function getProxyPassword() 798 { 799 return $this->_proxy_password; 800 } 801 802 /** 803 * Set Stream Context 804 * 805 * @return Zend_Soap_Client 806 */ 807 public function setStreamContext($context) 808 { 809 if(!is_resource($context) || get_resource_type($context) !== "stream-context") { 810 /** 811 * @see Zend_Soap_Client_Exception 812 */ 813 require_once "Zend/Soap/Client/Exception.php"; 814 throw new Zend_Soap_Client_Exception( 815 "Invalid stream context resource given." 816 ); 817 } 818 819 $this->_stream_context = $context; 820 return $this; 821 } 822 823 /** 824 * Get Stream Context 825 * 826 * @return resource 827 */ 828 public function getStreamContext() 829 { 830 return $this->_stream_context; 831 } 832 833 /** 834 * Set the SOAP Feature options. 835 * 836 * @param string|int $feature 837 * @return Zend_Soap_Client 838 */ 839 public function setSoapFeatures($feature) 840 { 841 $this->_features = $feature; 842 843 $this->_soapClient = null; 844 return $this; 845 } 846 847 /** 848 * Return current SOAP Features options 849 * 850 * @return int 851 */ 852 public function getSoapFeatures() 853 { 854 return $this->_features; 855 } 856 857 /** 858 * Set the SOAP Wsdl Caching Options 859 * 860 * @param string|int|boolean $caching 861 * @return Zend_Soap_Client 862 */ 863 public function setWsdlCache($options) 864 { 865 $this->_cache_wsdl = $options; 866 return $this; 867 } 868 869 /** 870 * Get current SOAP Wsdl Caching option 871 */ 872 public function getWsdlCache() 873 { 874 return $this->_cache_wsdl; 875 } 876 877 /** 878 * Set the string to use in User-Agent header 879 * 880 * @param string|null $userAgent 881 * @return Zend_Soap_Client 882 */ 883 public function setUserAgent($userAgent) 884 { 885 if ($userAgent === null) { 886 $this->_user_agent = null; 887 } else { 888 $this->_user_agent = (string)$userAgent; 889 } 890 return $this; 891 } 892 893 /** 894 * Get current string to use in User-Agent header 895 * 896 * @return string|null 897 */ 898 public function getUserAgent() 899 { 900 return $this->_user_agent; 901 } 902 903 /** 904 * Retrieve request XML 905 * 906 * @return string 907 */ 908 public function getLastRequest() 909 { 910 if ($this->_soapClient !== null) { 911 return $this->_soapClient->__getLastRequest(); 912 } 913 914 return ''; 915 } 916 917 /** 918 * Get response XML 919 * 920 * @return string 921 */ 922 public function getLastResponse() 923 { 924 if ($this->_soapClient !== null) { 925 return $this->_soapClient->__getLastResponse(); 926 } 927 928 return ''; 929 } 930 931 /** 932 * Retrieve request headers 933 * 934 * @return string 935 */ 936 public function getLastRequestHeaders() 937 { 938 if ($this->_soapClient !== null) { 939 return $this->_soapClient->__getLastRequestHeaders(); 940 } 941 942 return ''; 943 } 944 945 /** 946 * Retrieve response headers (as string) 947 * 948 * @return string 949 */ 950 public function getLastResponseHeaders() 951 { 952 if ($this->_soapClient !== null) { 953 return $this->_soapClient->__getLastResponseHeaders(); 954 } 955 956 return ''; 957 } 958 959 /** 960 * Retrieve last invoked method 961 * 962 * @return string 963 */ 964 public function getLastMethod() 965 { 966 return $this->_lastMethod; 967 } 968 969 /** 970 * Do request proxy method. 971 * 972 * May be overridden in subclasses 973 * 974 * @internal 975 * @param Zend_Soap_Client_Common $client 976 * @param string $request 977 * @param string $location 978 * @param string $action 979 * @param int $version 980 * @param int $one_way 981 * @return mixed 982 */ 983 public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) 984 { 985 // Perform request as is 986 if ($one_way == null) { 987 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); 988 } else { 989 return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); 990 } 991 } 992 993 /** 994 * Initialize SOAP Client object 995 * 996 * @throws Zend_Soap_Client_Exception 997 */ 998 protected function _initSoapClientObject() 999 { 1000 $wsdl = $this->getWsdl(); 1001 $options = array_merge($this->getOptions(), array('trace' => true)); 1002 1003 if ($wsdl == null) { 1004 if (!isset($options['location'])) { 1005 require_once 'Zend/Soap/Client/Exception.php'; 1006 throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); 1007 } 1008 if (!isset($options['uri'])) { 1009 require_once 'Zend/Soap/Client/Exception.php'; 1010 throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); 1011 } 1012 } else { 1013 if (isset($options['use'])) { 1014 require_once 'Zend/Soap/Client/Exception.php'; 1015 throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); 1016 } 1017 if (isset($options['style'])) { 1018 require_once 'Zend/Soap/Client/Exception.php'; 1019 throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); 1020 } 1021 } 1022 unset($options['wsdl']); 1023 1024 $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options); 1025 } 1026 1027 1028 /** 1029 * Perform arguments pre-processing 1030 * 1031 * My be overridden in descendant classes 1032 * 1033 * @param array $arguments 1034 */ 1035 protected function _preProcessArguments($arguments) 1036 { 1037 // Do nothing 1038 return $arguments; 1039 } 1040 1041 /** 1042 * Perform result pre-processing 1043 * 1044 * My be overridden in descendant classes 1045 * 1046 * @param array $arguments 1047 */ 1048 protected function _preProcessResult($result) 1049 { 1050 // Do nothing 1051 return $result; 1052 } 1053 1054 /** 1055 * Add SOAP input header 1056 * 1057 * @param SoapHeader $header 1058 * @param boolean $permanent 1059 * @return Zend_Soap_Client 1060 */ 1061 public function addSoapInputHeader(SoapHeader $header, $permanent = false) 1062 { 1063 if ($permanent) { 1064 $this->_permanentSoapInputHeaders[] = $header; 1065 } else { 1066 $this->_soapInputHeaders[] = $header; 1067 } 1068 1069 return $this; 1070 } 1071 1072 /** 1073 * Reset SOAP input headers 1074 * 1075 * @return Zend_Soap_Client 1076 */ 1077 public function resetSoapInputHeaders() 1078 { 1079 $this->_permanentSoapInputHeaders = array(); 1080 $this->_soapInputHeaders = array(); 1081 1082 return $this; 1083 } 1084 1085 /** 1086 * Get last SOAP output headers 1087 * 1088 * @return array 1089 */ 1090 public function getLastSoapOutputHeaderObjects() 1091 { 1092 return $this->_soapOutputHeaders; 1093 } 1094 1095 /** 1096 * Perform a SOAP call 1097 * 1098 * @param string $name 1099 * @param array $arguments 1100 * @return mixed 1101 */ 1102 public function __call($name, $arguments) 1103 { 1104 $soapClient = $this->getSoapClient(); 1105 1106 $this->_lastMethod = $name; 1107 1108 $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); 1109 $result = $soapClient->__soapCall($name, 1110 $this->_preProcessArguments($arguments), 1111 null, /* Options are already set to the SOAP client object */ 1112 (count($soapHeaders) > 0)? $soapHeaders : null, 1113 $this->_soapOutputHeaders); 1114 1115 // Reset non-permanent input headers 1116 $this->_soapInputHeaders = array(); 1117 1118 return $this->_preProcessResult($result); 1119 } 1120 1121 1122 /** 1123 * Return a list of available functions 1124 * 1125 * @return array 1126 * @throws Zend_Soap_Client_Exception 1127 */ 1128 public function getFunctions() 1129 { 1130 if ($this->getWsdl() == null) { 1131 require_once 'Zend/Soap/Client/Exception.php'; 1132 throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); 1133 } 1134 1135 $soapClient = $this->getSoapClient(); 1136 return $soapClient->__getFunctions(); 1137 } 1138 1139 1140 /** 1141 * Get used types. 1142 * 1143 * @return array 1144 */ 1145 1146 /** 1147 * Return a list of SOAP types 1148 * 1149 * @return array 1150 * @throws Zend_Soap_Client_Exception 1151 */ 1152 public function getTypes() 1153 { 1154 if ($this->getWsdl() == null) { 1155 require_once 'Zend/Soap/Client/Exception.php'; 1156 throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); 1157 } 1158 1159 $soapClient = $this->getSoapClient(); 1160 1161 return $soapClient->__getTypes(); 1162 } 1163 1164 /** 1165 * @param SoapClient $soapClient 1166 * @return Zend_Soap_Client 1167 */ 1168 public function setSoapClient(SoapClient $soapClient) 1169 { 1170 $this->_soapClient = $soapClient; 1171 return $this; 1172 } 1173 1174 /** 1175 * @return SoapClient 1176 */ 1177 public function getSoapClient() 1178 { 1179 if ($this->_soapClient == null) { 1180 $this->_initSoapClientObject(); 1181 } 1182 return $this->_soapClient; 1183 } 1184 1185 /** 1186 * @param string $name 1187 * @param string $value 1188 * @return Zend_Soap_Client 1189 */ 1190 public function setCookie($cookieName, $cookieValue=null) 1191 { 1192 $soapClient = $this->getSoapClient(); 1193 $soapClient->__setCookie($cookieName, $cookieValue); 1194 return $this; 1195 } 1196 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |