3

我是 REST API 的新手。我正在尝试使用更新的网站设计将 Web 应用程序转换为 REST-ful。

我在开发服务器上的工作环境是 Coldfusion10,Windows 2008 R2 Server。到目前为止,我成功地将 REST 服务注册到 ColdFusion 10 服务器的 Web 根目录,并且工作正常。

但是,我需要在站点目录中注册 REST 服务。我已经这样做了,它工作了几次,但是,大多数时候我在编辑 CFC 后收到 500 错误(将字符串cfreturn从“foo”更改为“foo2”)。我通过直接通过 url 验证了 CFC 的语法,没问题。我尝试在管理员中添加 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'' " 

谢谢,

热那

4

0 回答 0