Coldfusion 执行cfc时出错:函数返回的值不是json类型

Coldfusion 执行cfc时出错:函数返回的值不是json类型,coldfusion,cfc,Coldfusion,Cfc,我在ColdFusion中编写了一个web服务,它通过检查数据库中的输入值来返回消息(成功/失败)。 要运行cfc,我直接在URL中提供参数,如下所示: 但当我运行此页面时,它以如下错误结束: 这是我的CFC: <cfcomponent rest="true" restpath="/AimsWeb"> <!--- REST Service---> <cffunction name="AuthenticateUser" access="remote" httpm

我在ColdFusion中编写了一个web服务,它通过检查数据库中的输入值来返回消息(成功/失败)。 要运行cfc,我直接在URL中提供参数,如下所示: 但当我运行此页面时,它以如下错误结束:

这是我的CFC:

<cfcomponent rest="true" restpath="/AimsWeb"> <!--- REST Service--->

<cffunction name="AuthenticateUser" access="remote" httpmethod="POST"  returnFormat="JSON" returntype="json">

<!---- Defining Arguments--->
    <cfargument name="Username" type="string" required="Yes">
    <cfargument name="Password" type="string" required="Yes">
    <cfargument name="CustomerID" type="string" required="Yes">

<!---- Setting the Form Values (which we will get from AW+) and setting it to arguments passed--->
    <cfset Form.CustomerID = arguments.CustomerID>
    <cfset Form.Username = arguments.Username>
    <cfset Form.Password = Hash(arguments.Password)>

<cfif StructKeyExists (form, 'CustomerID') and StructKeyExists(form, 'UserName') and StructKeyExists (form, 'password')>
   <cfquery name="AllUsers" datasource="#Application.GomDatasource#">
    SELECT u.UserTypeID, u.UserID, u.CustomerID, u.UserName, u.Password
     FROM tblUsers u
    WHERE u.CustomerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#Form.CustomerID#">
   </cfquery>



<!--- This is to check whether provided parameters are valid by checking the same in the database--->
<cfset local.StatusStruct = StructNew()>

<cfif form.customerid EQ "" OR form.username EQ "" OR form.password EQ "">
    <cfset local.StatusStruct['errorCode'] = 400>
    <cfset local.StatusStruct['errorMessage'] = "Insufficient Input.">

<cfelseif AllUsers.RecordCount AND form.CustomerId EQ AllUsers.CustomerID AND form.username EQ AllUsers.UserName AND form.password EQ AllUsers.Password>
    <cfset local.StatusStruct['errorCode'] = 200>
    <cfset local.StatusStruct['errorMessage'] = "Success">

<cfelseif AllUsers.CustomerID NEQ form.CustomerID>
    <cfset local.StatusStruct['errorCode'] = 400>
    <cfset local.StatusStruct['errorMessage'] = "Customer Id doesn't exist">

 <cfelseif AllUsers.UserName NEQ form.UserName>
    <cfset local.StatusStruct['errorCode'] = 400>
    <cfset local.StatusStruct['errorMessage'] = "User not found">

 <cfelseif AllUsers.Password NEQ form.password>
    <cfset local.StatusStruct['errorCode'] = 400>
    <cfset local.StatusStruct['errorMessage'] = "Invalid Password">
</cfif>

    <!--- Returning the status in JSON form--->

</cfif>
<cfreturn local.StatusStruct>
  </cffunction>

</cfcomponent>

选择u.UserTypeID、u.UserID、u.CustomerID、u.UserName、u.Password
来自特布卢斯大学
其中u.CustomerID=

谁能帮帮我吗?

它奏效了。
returntype=json
无效。我去掉了那条线,它就成功了

<cffunction name="AuthenticateUser" access="remote" httpmethod="GET"  returnFormat="JSON">


谢谢大家的帮助。

将local.StatusStruct转换为json的部分在哪里?url中的用户和密码…为什么?@DanBracuk:我相信如果我们指定returnFormat=“json”,这将自动将返回值转换为json字符串。。(?)@Hackerman:我只是传递用户名、密码作为运行cfc的参数(因为我不想编写调用页面),而且您正在将该url粘贴到浏览器中,然后这是一个get请求……您需要执行post请求,因为您有这个
httpmethod=“post”