Chinaunix首页 | 论坛 | 博客
  • 博客访问: 891712
  • 博文数量: 91
  • 博客积分: 803
  • 博客等级: 准尉
  • 技术积分: 1051
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-24 13:42
文章分类

全部博文(91)

文章存档

2021年(1)

2020年(4)

2019年(4)

2018年(9)

2017年(11)

2016年(11)

2015年(6)

2014年(3)

2013年(28)

2012年(14)

分类: PHP

2013-01-16 15:45:54

如果服务器安装了eAccelerator, 默认优化的时候删除了PHP的文档块并缓存代码编译结果,所有调用反射接口的时候返回false ,导致yii调用wsdl文件找不到方法.

现修改代码如下:

CWebService.php  中 generateWsdl方法


	public function generateWsdl()
	{
		$providerClass=is_object($this->provider) ? get_class($this->provider) : Yii::import($this->provider,true);
		$key='Yii-CWebService-'.$providerClass.'.txt';
		$generator=new CWsdlGenerator;
		$wsdl=$generator->generateWsdl($providerClass,$this->serviceUrl,$this->encoding);

		//wsdl dir
		$wsdl_cache_dir = './protected/wsdl/';
		if(!is_dir($wsdl_cache_dir))
		{
			mkdir($wsdl_cache_dir);
		}
		//get file update time
		$php_class_file_path = './protected/controllers/'.$providerClass.'.php';
		$last_up_time = filemtime($php_class_file_path);
		$time_key = 'Yii-CWebService-time-'.$providerClass.'.txt';
		if(file_exists($wsdl_cache_dir.$time_key))
		{
			$l_time = file_get_contents($wsdl_cache_dir.$time_key);
			if($last_up_time > $l_time)
			{
				file_put_contents($wsdl_cache_dir.$time_key , $last_up_time);
				file_put_contents($wsdl_cache_dir.$key , $wsdl);
				return $wsdl;
			}
			else
			{
				return file_get_contents($wsdl_cache_dir.$key);
			}
		}
		else
		{
			file_put_contents($wsdl_cache_dir.$time_key , $last_up_time);
			file_put_contents($wsdl_cache_dir.$key , $wsdl);
			return $wsdl;
		}
	}
将每次更新的接口php文件的更新时间做一个缓存,更新php文件的同时更新接口的wsdl文件。



阅读(4352) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~