无法添加最基本的RESTful Web服务

时间:2013-03-04 15:09:33

标签: web-services rest coldfusion

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

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

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

/index.cfm(理论上,由于不需要包含app vars的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 Admin中:

  • 根路径: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 

目前还不确定这是否是配置问题?这是related to my previous question,并尝试简化一切以隔离原因。

编辑#1 我能够将这个非常简单的RESTful服务添加到Windows 7 64位/ CF 10(无更新)而没有任何问题。我想知道这是我的安装是否已损坏或更新是否已损坏它?

编辑#2 我重新安装了我的CF服务器,它仍然给了我同样的问题。

编辑#3

根据milanchandna的建议,我遵循了以下步骤:

  1. 创建了一个文件夹c:\ websites \ milanchandna
  2. 在IIS中创建了一个新网站(使用同名apppool的milanchandna),并以root身份使用c:\​​ websites \ milanchandna,在端口8084上运行
  3. 创建了jakarta虚拟目录(需要这个)
  4. 添加了基本的HelloWorld.cfc
  5. 成功导航到HelloWorld.cfc,没有错误
  6. 在CF管理中,REST服务添加了以下内容:
  7. 根路径:C:/ websites / milanchandna /
  8. 服务映射:示例
  9. 点击添加服务
  10. 获取错误: 注册REST服务时出错。请确保您输入了正确的映射和路径。 无法初始化应用程序示例。 原因:应用程序不包含任何已启用的其他CFC。 该应用程序不包含任何其他启用的CFC。
  11. HelloWorld.cfc:

    <cfcomponent rest="true" restPath="/hello">
            <cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">
                     <cfset res="Hello World">
                     <cfreturn res>
            </cffunction>
    </cfcomponent>
    

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

由于这是一个不起作用的基本例子,我建议从开始跟随它。

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

    一样

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

  4. 检查是否会引发任何错误。如果是,那么CFC就存在问题。如果没有那么你就好了。

  5. 从管理员处将此文件夹注册为REST应用程序。
相关问题