我正在玩ColdFusion 10的RESTful Web服務。首先,我通過CF管理員註冊了一項休息服務。REST - 404未找到
C:/ ColdFusion10/cfusion/wwwroot/restful /並稱之爲IIT。
現在,我有C:/ColdFusion10/cfusion/wwwroot/restful/restTest.cfc是:
<cfcomponent restpath="IIT" 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:/ColdFusion10/cfusion/wwwroot/restful/callTest.cfm這有以下幾點:
<cfhttp url="http://127.0.0.1:8500/rest/IIT/restTest/getHandlerJSON/1" method="get" port="8500" result="res">
<cfhttpparam type="header" name="Accept" value="application/json">
</cfhttp>
<cfdump var="#res#">
當我運行callTest.cfm,我得到404未找到。我在這裏錯過了什麼?
真棒!謝謝。 – CFNinja