Changeset 21299 for branches/version-2_11-dev/data/module/SOAP/Client.php
- Timestamp:
- 2011/10/25 00:02:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_11-dev/data/module/SOAP/Client.php
r20119 r21299 23 23 */ 24 24 25 /** SOAP_Value */ 25 26 require_once 'SOAP/Value.php'; 26 27 require_once 'SOAP/Base.php'; … … 36 37 // these two are BC/FC handlers for call in PHP4/5 37 38 39 /** 40 * @package SOAP 41 */ 38 42 if (!class_exists('SOAP_Client_Overload')) { 39 43 if (substr(zend_version(), 0, 1) > 1) { … … 293 297 * placed in the options array. This is done to provide backwards 294 298 * compatibility with current clients, but may be removed in the future. 295 * The currently supported values are:<pre> 296 * namespace 297 * soapaction 298 * timeout (HTTP socket timeout) 299 * transfer-encoding (SMTP, Content-Transfer-Encoding: header) 300 * from (SMTP, From: header) 301 * subject (SMTP, Subject: header) 302 * headers (SMTP, hash of extra SMTP headers) 303 * </pre> 299 * The currently supported values are: 300 * - 'namespace' 301 * - 'soapaction' 302 * - 'timeout': HTTP socket timeout 303 * - 'transfer-encoding': SMTP transport, Content-Transfer-Encoding: header 304 * - 'from': SMTP transport, From: header 305 * - 'subject': SMTP transport, Subject: header 306 * - 'headers': SMTP transport, hash of extra SMTP headers 307 * - 'attachments': what encoding to use for attachments (Mime, Dime) 308 * - 'trace': whether to trace the SOAP communication 309 * - 'style': 'document' or 'rpc'; when set to 'document' the parameters 310 * are not wrapped inside a tag with the SOAP action name 311 * - 'use': 'literal' for literal encoding, anything else for section 5 312 * encoding; when set to 'literal' SOAP types will be omitted. 313 * - 'keep_arrays_flat': use the tag name multiple times for each element 314 * when passing in an array in literal mode 315 * - 'no_type_prefix': supress adding of the namespace prefix 304 316 * 305 317 * @access public … … 307 319 * @param string $method The method to call. 308 320 * @param array $params The method parameters. 309 * @param string|array $namespace Namespace or hash with options. 321 * @param string|array $namespace Namespace or hash with options. Note: 322 * most options need to be repeated for 323 * SOAP_Value instances. 310 324 * @param string $soapAction 311 325 * 312 326 * @return mixed The method result or a SOAP_Fault on error. 313 327 */ 314 function &call($method, &$params, $namespace = false, $soapAction = false)328 function call($method, $params, $namespace = false, $soapAction = false) 315 329 { 316 330 $this->headersIn = null; … … 333 347 if (!$this->_soap_transport || 334 348 $this->_endpoint != $this->_soap_transport->url) { 335 $this->_soap_transport = &SOAP_Transport::getTransport($this->_endpoint);349 $this->_soap_transport = SOAP_Transport::getTransport($this->_endpoint); 336 350 if (PEAR::isError($this->_soap_transport)) { 337 $fault = & $this->_soap_transport;351 $fault = $this->_raiseSoapFault($this->_soap_transport); 338 352 $this->_soap_transport = null; 339 $fault = $this->_raiseSoapFault($fault);340 353 return $fault; 341 354 } … … 366 379 $this->__result_encoding = $this->_soap_transport->result_encoding; 367 380 368 $result = &$this->parseResponse($this->xml, $this->__result_encoding,369 381 $result = $this->parseResponse($this->xml, $this->__result_encoding, 382 $this->_soap_transport->attachments); 370 383 return $result; 371 384 } … … 429 442 } 430 443 431 $return_value = &$this->call($method, $params);444 $return_value = $this->call($method, $params); 432 445 433 446 return true; … … 435 448 436 449 /** 437 * @deprecated Use getLastRequest().438 */439 function &__getlastrequest()440 {441 $request = $this->getLastRequest();442 return $request;443 }444 445 /**446 450 * Returns the XML content of the last SOAP request. 447 451 * … … 454 458 455 459 /** 456 * @deprecated Use getLastResponse().457 */458 function &__getlastresponse()459 {460 $response =& $this->getLastResponse;461 return $response;462 }463 464 /**465 460 * Returns the XML content of the last SOAP response. 466 461 * … … 473 468 474 469 /** 475 * @deprecated Use setUse().476 */477 function __use($use)478 {479 $this->setUse($use);480 }481 482 /**483 470 * Sets the SOAP encoding. 484 471 * 472 * The default encoding is section 5 encoded. 473 * 485 474 * @param string $use Either 'literal' or 'encoded' (section 5). 486 475 */ … … 491 480 492 481 /** 493 * @deprecated Use setStyle().494 */495 function __style($style)496 {497 $this->setStyle($style);498 }499 500 /**501 482 * Sets the SOAP encoding style. 502 483 * 484 * The default style is rpc. 485 * 503 486 * @param string $style Either 'document' or 'rpc'. 504 487 */ … … 509 492 510 493 /** 511 * @deprecated Use setTrace().512 */513 function __trace($level)514 {515 $this->setTrace($level);516 }517 518 /**519 494 * Sets whether to trace the traffic on the transport level. 520 495 * … … 528 503 } 529 504 530 function _generate($method, &$params, $namespace = false, 505 /** 506 * Generates the complete XML SOAP message for an RPC call. 507 * 508 * @see call() 509 * 510 * @param string $method The method to call. 511 * @param array $params The method parameters. 512 * @param string|array $namespace Namespace or hash with options. Note: 513 * most options need to be repeated for 514 * SOAP_Value instances. 515 * @param string $soapAction 516 * 517 * @return string The SOAP message including envelope. 518 */ 519 function _generate($method, $params, $namespace = false, 531 520 $soapAction = false) 532 521 { 533 522 $this->fault = null; 534 $this->_options['input'] = 'parse'; 523 $this->_options['input'] = 'parse'; 535 524 $this->_options['result'] = 'parse'; 536 525 $this->_options['parameters'] = false; 537 526 538 if ($params && gettype($params) != 'array') {527 if ($params && !is_array($params)) { 539 528 $params = array($params); 540 529 } 541 530 542 if (gettype($namespace) == 'array') { 531 if (is_array($namespace)) { 532 // Options passed as a hash. 543 533 foreach ($namespace as $optname => $opt) { 544 534 $this->_options[strtolower($optname)] = $opt; 545 }546 if (isset($this->_options['namespace'])) {547 $namespace = $this->_options['namespace'];548 } else {549 $namespace = false;550 535 } 551 536 } else { 552 537 // We'll place $soapAction into our array for usage in the 553 538 // transport. 554 $this->_options['soapaction'] = $soapAction; 555 $this->_options['namespace'] = $namespace; 539 if ($soapAction) { 540 $this->_options['soapaction'] = $soapAction; 541 } 542 if ($namespace) { 543 $this->_options['namespace'] = $namespace; 544 } 545 } 546 if (isset($this->_options['namespace'])) { 547 $namespace = $this->_options['namespace']; 548 } else { 549 $namespace = false; 556 550 } 557 551 … … 579 573 return $this->_raiseSoapFault($opData); 580 574 } 581 $namespace = $opData['namespace'];582 $this->_options['style'] = $opData['style'];583 $this->_options['use'] = $opData['input']['use'];575 $namespace = $opData['namespace']; 576 $this->_options['style'] = $opData['style']; 577 $this->_options['use'] = $opData['input']['use']; 584 578 $this->_options['soapaction'] = $opData['soapAction']; 585 579 … … 649 643 $this->docparams = true; 650 644 $mqname = new QName($method, $namespace); 651 $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params); 645 $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params, 646 array(), $this->_options); 652 647 $soap_msg = $this->makeEnvelope($methodValue, 653 648 $this->headersOut, … … 657 652 if (!$params) { 658 653 $mqname = new QName($method, $namespace); 659 $mynull = null; 660 $params = new SOAP_Value($mqname->fqn(), 'Struct', $mynull); 654 $params = new SOAP_Value($mqname->fqn(), 'Struct', null); 661 655 } elseif ($this->_options['input'] == 'parse') { 662 656 if (is_array($params)) { … … 686 680 $this->_options); 687 681 } 688 unset($this->headersOut);682 $this->headersOut = null; 689 683 690 684 if (PEAR::isError($soap_msg)) { … … 728 722 729 723 /** 730 * @deprecated Use parseResponse().731 */732 function &__parse(&$response, $encoding, &$attachments)733 {734 return $this->parseResponse($response, $encoding, $attachments);735 }736 737 /**738 724 * Parses a SOAP response. 739 725 * … … 744 730 * @param array $attachments List of attachments. 745 731 */ 746 function &parseResponse($response, $encoding, &$attachments)732 function parseResponse($response, $encoding, $attachments) 747 733 { 748 734 // Parse the response. 749 $response = &new SOAP_Parser($response, $encoding, $attachments);735 $response = new SOAP_Parser($response, $encoding, $attachments); 750 736 if ($response->fault) { 751 $fault = &$this->_raiseSoapFault($response->fault);737 $fault = $this->_raiseSoapFault($response->fault); 752 738 return $fault; 753 739 } 754 740 755 741 // Return array of parameters. 756 $return = &$response->getResponse();757 $headers = &$response->getHeaders();742 $return = $response->getResponse(); 743 $headers = $response->getHeaders(); 758 744 if ($headers) { 759 $this->headersIn = &$this->_decodeResponse($headers, false);760 } 761 762 $decoded = &$this->_decodeResponse($return);745 $this->headersIn = $this->_decodeResponse($headers, false); 746 } 747 748 $decoded = $this->_decodeResponse($return); 763 749 return $decoded; 764 750 } 765 751 766 752 /** 767 * Converts a complex SOAP_Value into a PHP Array 768 * 769 * @param SOAP_Value $response value object 770 * @param boolean $shift FIXME 771 * @return Array 772 */ 773 function &_decodeResponse($response, $shift = true) 753 * Converts a complex SOAP_Value into a PHP Array 754 * 755 * @param SOAP_Value $response Value object. 756 * @param boolean $shift 757 * 758 * @return array 759 */ 760 function _decodeResponse($response, $shift = true) 774 761 { 775 762 if (!$response) { … … 780 767 // Check for valid response. 781 768 if (PEAR::isError($response)) { 782 $fault = &$this->_raiseSoapFault($response);769 $fault = $this->_raiseSoapFault($response); 783 770 return $fault; 784 771 } elseif (!is_a($response, 'soap_value')) { 785 $fault = &$this->_raiseSoapFault("Didn't get SOAP_Value object back from client");772 $fault = $this->_raiseSoapFault("Didn't get SOAP_Value object back from client"); 786 773 return $fault; 787 774 } 788 775 789 776 // Decode to native php datatype. 790 $returnArray = &$this->_decode($response);777 $returnArray = $this->_decode($response); 791 778 792 779 // Fault? 793 780 if (PEAR::isError($returnArray)) { 794 $fault = &$this->_raiseSoapFault($returnArray);781 $fault = $this->_raiseSoapFault($returnArray); 795 782 return $fault; 796 783 } … … 800 787 $returnArray = get_object_vars($returnArray); 801 788 } 789 802 790 if (is_array($returnArray)) { 803 791 if (isset($returnArray['faultcode']) || 804 isset($returnArray[ 'SOAP-ENV:faultcode'])) {792 isset($returnArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) { 805 793 $faultcode = $faultstring = $faultdetail = $faultactor = ''; 806 794 foreach ($returnArray as $k => $v) { … … 810 798 if (stristr($k, 'faultactor')) $faultactor = $v; 811 799 } 812 $fault =& $this->_raiseSoapFault($faultstring, $faultdetail, $faultactor, $faultcode); 800 $fault = $this->_raiseSoapFault($faultstring, $faultdetail, 801 $faultactor, $faultcode); 813 802 return $fault; 814 803 } … … 820 809 return $returnArray; 821 810 } 811 822 812 return $returnArray; 823 }824 825 /**826 * @deprecated Use getWire().827 */828 function __get_wire()829 {830 return $this->getWire();831 813 } 832 814
Note: See TracChangeset
for help on using the changeset viewer.