ZF-6234: The WSDL setComplexTypeStrategy function dont load the Strategy include


The param $strategy recive the values of:

Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex ...

but when you set the value for example "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex" the function try to create the class "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex" but without the include of the strategy files.

I just did a patch for my projects, but require a general solution.

     * Set a strategy for complex type detection and handling
     * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions.
     * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy
     * @return Zend_Soap_Wsdl
    public function setComplexTypeStrategy($strategy)
        if($strategy === true) {
            require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php";
            $strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType();
        } else if($strategy === false) {
            require_once "Zend/Soap/Wsdl/Strategy/AnyType.php";
            $strategy = new Zend_Soap_Wsdl_Strategy_AnyType();
        } else if(is_string($strategy)) {
//----------- Here --------------
            require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php";
//----------- End Here --------------

            if(class_exists($strategy)) {
                $strategy = new $strategy();
            } else {
                require_once "Zend/Soap/Wsdl/Exception.php";
                throw new Zend_Soap_Wsdl_Exception(
                    sprintf("Strategy with name '%s does not exist.", $strategy

        if(!($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface)) {
            require_once "Zend/Soap/Wsdl/Exception.php";
            throw new Zend_Soap_Wsdl_Exception("Set a strategy that is not of type 'Zend_Soap_Wsdl_Strategy_Interface'");
        $this->_strategy = $strategy;
        return $this;



There are several sides to this issue:

  1. class_exists triggers an autoload, if a handler is registered.
  2. i don't want to add an dependency to Zend_Loader which i would have to do to call:


at that point.

  1. require_once alone does not work, since you have to load a file and not a class.

The dependency between the strategy and the wsdl class has to be wired in userland code, since there it is made explicit:

require_once 'MyWsdlStrategy.php';
$wsdl  = new Zend_Soap_Wsdl();
$wsdl->setComplexTypeStrategy(new MyStrategy());