4

我在使用 CF10(64 位)(开发版?)的 Windows 2008 R2(64 位)上

我正在尝试实现这个非常基本的教程:http: //blogs.coldfusion.com/post.cfm/rest-support-in-coldfusion-part-i

我通过 IIS 在 8081 端口上创建了一个新网站,然后添加了两个文件:

/index.cfm(理论上,因为不需要包含应用程序变量的 application.cfc,我可以跳过这个)

<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 的建议,我按照以下步骤操作:

  1. 创建了一个文件夹 c:\websites\milanchandna
  2. 在 IIS 中创建了一个新网站(milanchandna 使用同名的 apppool)并使用 c:\websites\milanchandna 作为 root,在端口 8084 上运行
  3. 创建了 jakarta 虚拟目录(需要这个)
  4. 添加了基本的 HelloWorld.cfc
  5. 成功导航到 HelloWorld.cfc,没有错误
  6. 在 CF Admin、REST Services 中,添加了以下内容:
  7. 根路径:C:/websites/milanchandna/
  8. 服务映射:示例
  9. 点击添加服务
  10. 获取错误:注册 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>
4

2 回答 2

1

我在 C:\ColdFusion10\cfusion\wwwroot(而不是站点的 IIS 根目录)下创建了文件,并且能够通过管理控制台注册 REST 服务而没有任何问题。

于 2013-03-28T15:13:23.847 回答
0

由于这是一个不起作用的基本示例,我建议从一开始就遵循它。

  1. 在 IIS webroot 中创建一个全新的文件夹。这不应位于已用于 CF REST 的任何文件夹中。
  2. 只需在此文件夹中放置一个简单的 rest cfc 即可。您的问题描述中给出的 CFC 示例看起来不错,让我们使用它。
  3. 从浏览器访问此 CFC,就像访问任何 cfm

    例如:[http://mysite:8081/mypath_to_cfc/mycfc.cfc]

  4. 检查这是否会引发任何错误。如果是这样,则 CFC 存在问题。如果没有,那么你很高兴。

  5. 将此文件夹注册为管理员的 REST 应用程序。
于 2013-03-11T12:58:22.617 回答