2
0
Просмотр исходного кода

fixed Proxy Soap class

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24744 44c647ce-9c0f-0410-b52a-842ac1e357ba
ezimuel 13 лет назад
Родитель
Сommit
e5d7fcf95f
3 измененных файлов с 33 добавлено и 14 удалено
  1. 2 2
      library/Zend/Soap/Server.php
  2. 29 10
      library/Zend/Soap/Server/Proxy.php
  3. 2 2
      tests/Zend/Soap/ServerTest.php

+ 2 - 2
library/Zend/Soap/Server.php

@@ -271,7 +271,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
         }
 
         if (null !== $this->_wsiCompliant) {
-            $options['ws_i'] = $this->_wsiCompliant;
+            $options['wsi_compliant'] = $this->_wsiCompliant;
         }
         
         return $options;
@@ -863,7 +863,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
         } catch (Zend_Soap_Server_Exception $e) {
             $setRequestException = $e;
         }
-
+        
         $soap = $this->_getSoap();
 
         ob_start();

+ 29 - 10
library/Zend/Soap/Server/Proxy.php

@@ -25,15 +25,26 @@ class Zend_Soap_Server_Proxy
     /**
      * @var object
      */
-    protected $_service;
+    protected $_classInstance;
+    /**
+     * @var string
+     */
+    protected $_className;
     /**
      * Constructor
      * 
      * @param object $service 
      */
-    public function  __construct($service)
+    public function  __construct($className, $classArgs = array())
     {
-        $this->_service = $service;
+        $class = new ReflectionClass($className);
+        $constructor = $class->getConstructor();
+	if ($constructor === null) {
+            $this->_classInstance = $class->newInstance();
+	} else {
+            $this->_classInstance = $class->newInstanceArgs($classArgs);
+	}
+	$this->_className = $className;
     }
     /**
      * Proxy for the WS-I compliant call
@@ -44,13 +55,21 @@ class Zend_Soap_Server_Proxy
      */
     public function __call($name, $arguments)
     {
-        $params = array();
-        if(count($arguments) > 0){
-            foreach($arguments[0] as $property => $value){
-                $params[$property] = $value;
-            }
-        }
-        $result = call_user_func_array(array($this->_service, $name), $params);
+        $result = call_user_func_array(array($this->_classInstance, $name), $this->_preProcessArguments($arguments));
         return array("{$name}Result"=>$result);
     }
+    /**
+     *  Pre process arguments
+     * 
+     * @param  mixed $arguments
+     * @return array 
+     */
+    protected function _preProcessArguments($arguments)
+    {
+        if (count($arguments) == 1 && is_object($arguments[0])) {
+            return get_object_vars($arguments[0]);
+	} else {
+            return $arguments;
+	}
+    }
 }

+ 2 - 2
tests/Zend/Soap/ServerTest.php

@@ -593,7 +593,7 @@ class Zend_Soap_ServerTest extends PHPUnit_Framework_TestCase
                              . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
           .     '<SOAP-ENV:Body>'
           .         '<ns1:testFunc2>'
-          .             '<param0 xsi:type="xsd:string">World</param0>'
+          .             '<who>World</who>'
           .         '</ns1:testFunc2>'
           .     '</SOAP-ENV:Body>'
           . '</SOAP-ENV:Envelope>' . "\n";
@@ -612,7 +612,7 @@ class Zend_Soap_ServerTest extends PHPUnit_Framework_TestCase
           .             '<return xsi:type="ns2:Map">'
           .                 '<item>'
           .                     '<key xsi:type="xsd:string">testFunc2Result</key>'
-          .                     '<value xsi:type="xsd:string">Hello !</value>'
+          .                     '<value xsi:type="xsd:string">Hello World!</value>'
           .                 '</item>'
           .             '</return>'
           .         '</ns1:testFunc2Response>'