如何在ColdFusion中为REST服务的表单范围传递参数?

时间:2014-10-31 13:58:48

标签: rest coldfusion coldfusion-10

今天在使用ColdFusion 10 REST时,我遇到了一些问题。我不知道如何将数据传递到FORM范围内的REST服务。 这是我启用REST的CFC,

<cfcomponent rest="true" restpath="/crudService" >

<cfset variable.myQuery = queryNew("Id,Name","Integer,Varchar",[[1,"Test1"],[2,"Test2"],[3,"Test3"]] )>

<cffunction name="getHandlerJSONForm" access="remote" httpmethod="GET" restpath="/formtest" returntype="query" produces="application/xml">
    <cfargument name="customerID" required="true" restargsource="Form"   type="numeric" >

        <cfquery dbtype="query" name="local.qryGetUserName">
            SELECT  Name
            FROM    variable.myQuery
            WHERE   Id = <cfqueryparam cfsqltype="cf_sql_integer" value="#customerID#">
        </cfquery>

        <cfreturn local.qryGetUserName>

</cffunction>

</cfcomponent>

这是CFM代码,调用REST服务,

<cfset restInitApplication("E:\Local Workspace\cfcs\rest","myfirstrest")>

<cfhttp url="http://cflocal.com/rest/myfirstrest/crudService/formtest" method="get" >
  <cfhttpparam  type="header" name="Content-Type" value="application/x-www-form-urlencoded" >
  <cfhttpparam type="formfield" name="customerID" value="1" >
</cfhttp>

<cfdump var="#cfhttp#">

在StatusCode中我得到500 Exception obtaining parameters

请说明这里出了什么问题。

0 个答案:

没有答案