Proxy.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 AutoDiscover
  18. * @copyright Copyright (c) 2005-2015 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. class Zend_Soap_Server_Proxy
  23. {
  24. /**
  25. * @var object
  26. */
  27. protected $_classInstance;
  28. /**
  29. * @var string
  30. */
  31. protected $_className;
  32. /**
  33. * Constructor
  34. *
  35. * @param object $service
  36. */
  37. public function __construct($className, $classArgs = array())
  38. {
  39. $class = new ReflectionClass($className);
  40. $constructor = $class->getConstructor();
  41. if ($constructor === null) {
  42. $this->_classInstance = $class->newInstance();
  43. } else {
  44. $this->_classInstance = $class->newInstanceArgs($classArgs);
  45. }
  46. $this->_className = $className;
  47. }
  48. /**
  49. * Proxy for the WS-I compliant call
  50. *
  51. * @param string $name
  52. * @param string $arguments
  53. * @return array
  54. */
  55. public function __call($name, $arguments)
  56. {
  57. $result = call_user_func_array(array($this->_classInstance, $name), $this->_preProcessArguments($arguments));
  58. return array("{$name}Result"=>$result);
  59. }
  60. /**
  61. * Pre process arguments
  62. *
  63. * @param mixed $arguments
  64. * @return array
  65. */
  66. protected function _preProcessArguments($arguments)
  67. {
  68. if (count($arguments) == 1 && is_object($arguments[0])) {
  69. return get_object_vars($arguments[0]);
  70. } else {
  71. return $arguments;
  72. }
  73. }
  74. }