Bladeren bron

Allow the Zend_Soap_Wsdl class to be overridden in the AutoDiscovery process. This can allow non complex types declared in the DocBlocks to be translated to xsd types (xsd:token, xsd:datetime, etc.) if the name of the Zend_Soap_Wsdl subclass which overrides the getType() method is passed as the third parameter to the Zend_Soap_Wsdl constructor. Details of this issue are logged at http://framework.zend.com/issues/browse/ZF-9214

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21379 44c647ce-9c0f-0410-b52a-842ac1e357ba
rquadling 16 jaren geleden
bovenliggende
commit
4b0d6238d9
1 gewijzigde bestanden met toevoegingen van 44 en 2 verwijderingen
  1. 44 2
      library/Zend/Soap/AutoDiscover.php

+ 44 - 2
library/Zend/Soap/AutoDiscover.php

@@ -92,12 +92,20 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface
     protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http');
 
     /**
+     * Name of the class to handle the WSDL creation.
+     *
+     * @var string
+     */
+    protected $_wsdlClass = 'Zend_Soap_Wsdl';
+
+    /**
      * Constructor
      *
      * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy
      * @param string|Zend_Uri $uri
+     * @param string $wsdlClass
      */
-    public function __construct($strategy = true, $uri=null)
+    public function __construct($strategy = true, $uri=null, $wsdlClass=null)
     {
         $this->_reflection = new Zend_Server_Reflection();
         $this->setComplexTypeStrategy($strategy);
@@ -105,6 +113,10 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface
         if($uri !== null) {
             $this->setUri($uri);
         }
+
+        if($wsdlClass !== null) {
+            $this->setWsdlClass($wsdlClass);
+        }
     }
 
     /**
@@ -151,6 +163,36 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface
     }
 
     /**
+     * Set the name of the WSDL handling class.
+     *
+     * @see Zend_Soap_Exception
+     * @see Zend_Soap_Exception
+     * @throws Zend_Soap_AutoDiscover_Exception
+     * @param  string $wsdlClass
+     * @return Zend_Soap_AutoDiscover
+     */
+    public function setWsdlClass($wsdlClass)
+    {
+        if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) {
+            require_once "Zend/Soap/AutoDiscover/Exception.php";
+            throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string.");
+        }
+        $this->_wsdlClass = $wsdlClass;
+
+        return $this;
+    }
+
+    /**
+     * Return the name of the WSDL handling class.
+     *
+     * @return string
+     */
+    public function getWsdlClass()
+    {
+        return $this->_wsdlClass;
+    }
+
+    /**
      * Set options for all the binding operations soap:body elements.
      *
      * By default the options are set to 'use' => 'encoded' and
@@ -268,7 +310,7 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface
     {
         $uri = $this->getUri();
 
-        $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy);
+        $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy);
 
         // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
         $wsdl->addSchemaTypeSection();