我是REST API的新手。我正在尝试使用更新的网站设计将Web应用程序转换为REST-ful。
我在开发服务器上的工作环境是Coldfusion10,Windows 2008 R2 Server。 到目前为止,我已成功将REST服务注册到ColdFusion 10服务器的Web根目录,并且工作正常。
但是,我需要在站点的目录中注册REST服务。我已经这样做了几次,但是,在我编辑CFC(将cfreturn
中的字符串从“foo”更改为“foo2”)后,我大多数时间都收到500错误。我通过直接通过url验证了CFC的语法,确定。
我尝试在Administrator中添加REST服务,大多数时候我在管理员中添加错误时会出现错误:
•Unable to refresh REST service.
Application rc could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
我在Application.cfc
中添加了Web服务<cfcomponent output="false">
<cfset this.name = hash(getCurrentTemplatePath()) />
<cfset this.applicationTimeout = createTimeSpan( 0, 0, 1, 0 ) />
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false" hint="I initialize the request.">
<cfset restInitApplication("E:\flex\html\v4\rc","rc")>
<cfreturn true />
</cffunction>
</cfcomponent>
这是/rc/studentHandler.cfc
<cfcomponent restpath="student" rest="true">
<cffunction name="getMethod" access="remote" output="false" returntype="string" httpmethod="get">
<cfreturn "foo">
</cffunction>
</cfcomponent>
最后一个文件是student.cfm。我是从http://mydevip/v4/student.cfm
<cfhttp url="http://mydevip/rest/rc/student" method="get">
<cfoutput>#cfhttp.filecontent#</cfoutput>
我试图直接从url调用cfc,如果cfc在CF Web根文件夹http://mydevip/rest/rc/student
中有效,并且如果我在自定义目录中调用cfc,则会给出错误。
以下是application.log
中的错误"Error","ajp-bio-8012-exec-5","11/13/13","10:13:30","5C89BF4E37081433800CEF0D961170B0","object is not an instance of declaring class The specific sequence of files included or processed is: E:\flex\html\v4\rc\studentHandler.cfc'' "
谢谢,
颊