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