开发者

Trouble executing the Yii web service demo

I'm fairly new to Yii and am currently trying to use this framework to create some PHP web services. While trying to execute the brief tutorial on web services provided on the Yii web site http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice#declaring-web-service-action I ran into some trouble. Namely, I get a "Maximum execution time of 60 seconds exceede开发者_开发百科d" fatal error when executing the script. My guess is that the getPrice() method actually never gets called. I'd appreciate any suggestions related to why this may be happening. The contents of my index.php file are listed below. (Note that the Yii gramework is properly installed and I'm running PHP 5.3.0 with the php_soap extension).

<?php

$yii=dirname(__FILE__).'/../yii/framework/yii.php';
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);

class StockController extends CController{

function __construct(){
    parent::__construct($this->id, $this->module);
}

public function actions(){
    return array(
        'quote'=>array(
            'class'=>'CWebServiceAction',
        ),
    );
}

/**
 * @param string the symbol of the stock
 * @return float the stock price
 * @soap
*/
public function getPrice($symbol){
    $prices=array('IBM'=>100, 'GOOGLE'=>350);
    return isset($prices[$symbol])?$prices[$symbol]:0;
    //...return stock price for $symbol
}
}

$client=new SoapClient('http://localhost/SampleWebService/?r=stock/quote');
echo $client->getPrice('GOOGLE');
?>


It seems strange that you are declaring the call in the index.php entry script... I'm also not sure why you are overriding the constructor?

And I think, if this really in your entry script, you are missing call the create the application, either Yii::createWebApplication($config)->run(); or Yii::createConsoleApplication($config)->run();, depending on if you are running this as a web or console application.

Have you made sure that the application is running as expected without the SOAP/services stuff? I would set up a basic Hello World app (web or console), then try the web services.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜