我在使用CF10(64位)(开发者版?)的Windows 2008 R2(64位)系统。我正在尝试实现这个非常基础的教程:
http://blogs.coldfusion.com/post.cfm/rest-support-in-coldfusion-part-i
我通过IIS在8081端口创建了一个新网站,然后添加了两个文件:
/index.cfm(理论上,因为没有需要包含应用程序变量的application.cfc,我可以跳过这一步)。
在CF管理界面中:
根路径:
一些系统信息:
<cfset s = "Hello World!">
<cfoutput>#s#</cfoutput>
/RestExample/HelloWorld.cfc
<cfcomponent rest="true" restPath="/hello">
<cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">
<cfset res="Hello World">
<cfreturn res>
</cffunction>
</cfcomponent>
在CF管理界面中:
根路径:
C:/websites/test/RestExample/
服务映射:Example
我收到以下错误信息:Error registering REST service. Please ensure that you have entered a proper mapping and path.
Application Example could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
一些系统信息:
Server Product ColdFusion
Version 10,0,8,284032
Tomcat Version 7.0.23.0
Edition Developer
Serial Number Developer
Operating System Windows Server 2008 R2
OS Version 6.1
Update Level /C:/ColdFusion10/cfusion/lib/updates/chf10000008.jar
Adobe Driver Version 4.1 (Build 0001)
JVM Details
Java Version 1.6.0_29
Java Vendor Sun Microsystems Inc.
Java Vendor URL http://java.sun.com/
Java Home C:\ColdFusion10\jre
我不确定这是否是一个配置问题,这个问题与我的先前问题相关,我试图简化一切以分离出原因。
编辑 #1 我能够将这个非常简单的RESTful服务添加到Windows 7 64位/CF 10(没有更新)中,没有任何问题。我想知道是我的安装损坏了还是更新导致了它?
编辑 #2 我重新安装了CF服务器,但仍然遇到了同样的问题。
编辑 #3
根据milanchandna的建议,我按照以下步骤进行:
- 创建文件夹c:\websites\milanchandna
- 在IIS中创建了一个新的网站(名为milanchandna,使用与之同名的应用程序池),并将c:\websites\milanchandna用作根目录,在8084端口上运行
- 创建jakarta虚拟目录(需要)
- 添加了基本的HelloWorld.cfc
- 成功访问HelloWorld.cfc,无错误
- 在CF管理员中,REST服务,添加以下内容:
- 根路径:C:/websites/milanchandna/
- 服务映射:Example
- 单击“添加服务”
- 出现错误: 注册REST服务时出错。请确保您输入了正确的映射和路径。 无法初始化应用程序Example。 原因:应用程序不包含任何启用REST的CFC。 应用程序不包含任何启用REST的CFC。
HelloWorld.cfc:
<cfcomponent rest="true" restPath="/hello">
<cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">
<cfset res="Hello World">
<cfreturn res>
</cffunction>
</cfcomponent>