I’m testing the web services feature of Yii and I can’t correctly return an array of objects or consume it using a web service.
Using the blog demo that comes with Yii I modify the PostController.php and Post.php files with the code in the webservice special topic of the Yii’s guide. This code is:
class PostController extends CController
{
public function actions()
{
return array(
'service'=>array(
'class'=>'CWebServiceAction',
'classMap'=>array(
'Post'=>'Post', // or simply 'Post'
),
),
);
}
/**
* @return Post[] a list of posts
* @soap
*/
public function getPosts()
{
return Post::model()->findAll();
}
}
class Post extends CActiveRecord
{
/**
* @var integer post ID
* @soap
*/
public $id;
/**
* @var string post title
* @soap
*/
public $title;
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
When I try to consume this my httpd service loads the memory of the computer and finally the process fails and stop. This is the code where I try to use the array of posts.
$client=new SoapClient('webserviceaddress');
$posts = $client->getPosts();
.
I don’t know if the problem is when returning the data or reading it.