Use generated ActiveRecord class for Web Service


I am currently working on a Yii Web Service as desribed in the tutorial. One web service method should return an array of a certain class called customer and is defined as


	* @return Customer[] all customers

	* @soap


	public function getCustomers()


		return Customer::model()->findAll();


The customer class is a gii generated CActiveRecord derivation and the properties are therefore not included explicitly. So I am not able to annotate them with the @soap annotation to include them in the webservice. This leads to an empty definition of Customers in the wsdl file. If I add a definition manually just like


     * @var integer post ID

     * @soap


    public $pid;

to the Customer class it is included as it should.

Unfortunately there a really many attributes and I don’t want to include them by hand for each required class.

Any ideas how to get this done best? I thought about adding the @soap annotation to the property defintion created by gii at the beginning of the class


 * This is the model class for table "customer".


 * The followings are the available columns in table 'customer':

 * @property integer $id

 * @property string $name

 * @property string $department_1


but it didn’t work (or I misplaced it)

Thank you in advance!

I think it’s no big deal to use bulk replace for modifying the auto generated attribute list like I did here

  /** @soap @var string */ public $ItemId;

  /** @soap @var string */ public $VehicleId;

  /** @soap @var string */ public $FromLocation;

  /** @soap @var string */ public $FromZipcode;

  /** @soap @var string */ public $ToLocation;

  /** @soap @var string */ public $ToZipcode;



Actually any change you make to an AR is reverted/deleted everytime you use gii.

To avoid this problem we made a directory (in "models") just for the gii-models and one for the modified models.








The ar-models extend from the base-models and are mostly untouched. Sometimes we modify the rules a bit and, as you would want to do, add the @soap comments.

Would actually be interesting how other developers handle this.

Is a quite spread solution, is very practical when you have an ar that changes often, but you want to save some customization.