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

标签 web-services rest coldfusion

我在 Windows 2008 R2(64 位)上使用 CF10(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 
    

    不确定此时是否是配置问题?这是 related to my previous question ,并试图简化一切以找出原因。

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

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

    编辑 #3

    根据 milanchandna 的建议,我按照以下步骤操作:
  • 创建了一个文件夹 c:\websites\milanchandna
  • 在 IIS 中创建了一个新网站(milanchandna 使用同名的 apppool)并使用 c:\websites\milanchandna 作为 root,运行在端口 8084
  • 创建雅加达虚拟目录(需要这个)
  • 添加了基本的 HelloWorld.cfc
  • 导航到 HelloWorld.cfc 成功,没有错误
  • 在 CF Admin、REST 服务中,添加了以下内容:
  • 根路径:C:/websites/milanchandna/
  • 服务映射:示例
  • 点击添加服务
  • 获取错误:
    注册 REST 服务时出错。请确保您输入了正确的映射和路径。
    应用实例无法初始化。
    原因:该应用程序不包含任何启用了休息的 CFC。
    该应用程序不包含任何启用了休息的 CFC。

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

    最佳答案

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

    关于web-services - 无法添加最基本的 RESTful Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15204688/

    相关文章:

    java - 如何从 EJB 使用 Web 服务

    rest - Kubernetes Rest API 用于更改 Pod 中现有的 secret/configmap

    wcf - 将 REST 方法添加到 WCF 数据服务?

    Java jax-rs 服务器

    java - 给定一个 WSDL 文件,创建一个简单的 Java 客户端

    coldfusion - 如何在 ColdFusion 9 EXTJS 网格列上设置 typeAhead=true?

    coldfusion - 如何在 ColdFusion 中调用带有某些参数的 cfm 文件?

    coldfusion - 如何扩展 Coldfusion 中的 32 位限制?

    node.js - 在启动 Windows 上运行 nodejs 应用程序

    rest - 如何使用 BaseX RESTXQ 获取整个查询字符串?