我對Yii相當陌生,目前正嘗試使用此框架來創建一些PHP Web服務。在嘗試執行Yii網站http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice#declaring-web-service-action上提供的Web服務簡要教程時,我遇到了一些麻煩。也就是說,執行腳本時出現「超過60秒的最大執行時間」致命錯誤。我的猜測是getPrice()方法實際上永遠不會被調用。 我很感激任何有關爲什麼這可能會發生的建議。下面列出了我的index.php文件的內容。 (請注意,Yii gramework已正確安裝,並且正在運行帶有php_soap擴展名的PHP 5.3.0)。執行Yii Web服務演示時出現問題
<?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');
?>
我剛剛遇到了這個,這可能有所幫助:http://rowsandcolumns.blogspot.com/2011/02/yii-web-service-and-php-soap-client.html – thaddeusmt 2011-02-06 15:59:00