先记录生成webservice
在我们的控制器里面,定义以下函数,注意:getPrice函数前面的doxygen风格的注释不能缺失,否则生成的webservice会缺失信息,访问方式如下:
http://127.0.0.1:8080/testApp/index.php/my/xxxx,xxxx为actions方法里面的配置信息;
<?php
class MyController extends Controller{
/**
* Logs out the current user and redirect to homepage.
*/
public function actionTest(){
$this->render('test');
}
public function actions(){
return array(
'xxxx'=>array(
'class'=>'CWebServiceAction',
),
);
}
/**
* @return string
* @soap
*/
public function getTime(){
return 'time';
}
/**
* @param string
* @return float
* @soap
*/
public function getPrice($symbol){
return 2.0;
}
}
//-------------------------------------------------------------------------------------------------------------------------------
在test.php里面写上
ini_set ( 'soap.wsdl_cache_enable' , 0 );
ini_set ( 'soap.wsdl_cache_ttl' , 0 );
$client = new SoapClient('http://127.0.0.1:8080/yii/testApp/index.php?r=my/xxxx');
echo $client->getPrice('1111').$client->getTime();
红色不写的话,只能跑官方给的webservice例子,修改的webservice和增加的都无法使用。