【发布时间】:2014-01-30 02:53:21
【问题描述】:
我正在使用 ColdFusion 10 的 RESTful Web 服务。首先,我通过 CF admin 注册了一个 rest 服务。
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 Not Found。我在这里错过了什么?
【问题讨论】:
标签: rest coldfusion