ColdFusion REST 404

时间:2017-03-13 20:04:17

标签: rest coldfusion coldfusion-2016

我正在设置ColdFusion 2016 RESTful Web服务,但不断收到404错误。第一步,我通过CF管理员注册了休息服务。

C:\ users \ dev_2 \ ColdFusion Builder 2016 workspacce \ svn \ restful并称之为IIT。

现在,我有C:\ users \ dev_2 \ ColdFusion Builder 2016 workspacce \ svn \ restful \ restTest.cfc,这是:

<cfcomponent restpath="restTest" rest="true" >
<!--- handle GET request (httpmethod), take argument in restpath(restpath={customerID}), return query data in json format(produces=text/json) ---> 
<cffunction name="getHandlerJSON" access="remote" httpmethod="GET" restpath="{customerID}" returntype="query" produces="application/json"> 
    <cfargument name="customerID" required="true" restargsource="Path" type="numeric"> 
    <cfset myQuery = queryNew("id,name", "Integer,varchar", [[1, "Sagar"], [2, "Ganatra"]])> 
    <cfquery dbtype="query" name="resultQuery"> 
        select * from myQuery 
        where id = #arguments.customerID# 
    </cfquery> 
    <cfreturn resultQuery> 
</cffunction> 
</cfcomponent>  

我还创建了C:\ users \ dev_2 \ ColdFusion Builder 2016 workspacce \ svn \ restful \ Test.cfm,其中包含以下内容:

<cfhttp url="https://local.mydomain.com/rest/IIT/restTest/1" method="get" result="res">   
<cfhttpparam type="header" name="Accept" value="application/json">

当我运行Test.cfm时,我得到404 Not Found。我在这里错过了什么?我正在关注此链接的回复 REST - 404 Not Found但没有骰子。谢谢你的时间!

1 个答案:

答案 0 :(得分:3)

根本原因是因为coldfusion需要在设置其余服务之前映射其余的API目录。