CWebServices Complex / Composite types

Hi,

I’m evaluating Yii 1.1.3 for use in a SOA project and am having problems with complex (or composite) types. I have read other posts about this matter, but cannot seem to find a solution. I have also read this documentation page on the topic, but am still having problems. Here’s what I have:




<?

require_once('includes/dbaccess.php');

require_once('includes/test.php');


class WriteController extends CController

{

  public function actions()

  {

    return array(

      'methods' => array(

        'class' => 'CWebServiceAction',

	'classMap' => array(

	  'TestClass' => 'TestClass',

	),

      ),

    );

  }


  /**

   * method: submit_captured_data

   * Submits some arbitrary captured data.

   * Returns true.

   *

   * @param TestClass[] captured_data An array of captured data.

   * @return TestClass[] Testing testing testing.

   * @soap

   */

  public function submit_captured_data($captured_data)

  {

    $retval = $captured_data;

    return $retval;

  }

  ...



My includes/test.php looks like this:




<?

  class TestClass

  {

    /*

     * @var string

     * @soap

     */

    public $param1;

		

    /* 

     * @var string

     * @soap

     */

    public $param2;

  }

?>



The composite type TestData is not properly generated in the WSDL (no param1 and param2 of type string):




...

<xsd:schema targetNamespace="urn:WriteControllerwsdl">

  <xsd:complexType name="TestClassArray">

    <xsd:complexContent>

      <xsd:restriction base="soap-enc:Array">

        <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:TestClass[]"/>

      </xsd:restriction>

    </xsd:complexContent>

  </xsd:complexType>

  <xsd:complexType name="TestClass">

    <xsd:all/>

  </xsd:complexType>

...



Any help would be really appreciated.

Thanks in advance.

Did you disable the wsdl cache (or at least set it to a time frame you can afford to wait :) ). I like to use 60 seconds, that way I can see the difference.

/Tommy

Hi Tommy. Thanks for your reply. My SOAP cache is completely disabled (soap.wsdl_cache_enabled=0). Any changes I make to the SOAP methods are immediately available, so I don’t think it’s a cache problem.

I found the problem - it seems that Yii is very touchy about the asterisks characters in the comments:




<?

  class TestClass

  {

    /*

     * @var string

     * @soap

     */

    public $param1;

                

    /* 

     * @var string

     * @soap

     */

    public $param2;

  }



should have been:




<?

  class TestClass

  {

    /**

     * @var string

     * @soap

     **/

    public $param1;

                

    /** 

     * @var string

     * @soap

     **/

    public $param2;

  }



Interestingly, I found that the web service works fine even without classMap defined.

Yii is the coolest! ::)