【发布时间】:2013-03-30 01:55:53
【问题描述】:
有人知道如何解决这个问题吗?
"Unable to invoke CFC - The value returned from the getAllContacts function is not of type Contacts[].
如果将组件名称指定为返回类型,则可能找不到或无法访问该组件的定义文件。”
谢谢。
[更新]
当然:这是 ContactsService.cfc 中的代码:
<cfcomponent output="false">
<!--- [irrelevant code removed] --->
<cffunction name="getAllContacts" returntype="Contacts[]" access="remote">
<cfreturn entityload("Contacts") />
</cffunction>
<!--- [irrelevant code removed] --->
Contacts.cfc 中的代码:
<cfcomponent persistent="true" table="Contacts" output="false">
<cfproperty name="id" column="id" type="numeric" ormtype="int" fieldtype="id" />
<cfproperty name="company" column="company" type="string" ormtype="string" />
<cfproperty name="Sub_Heading" column="Sub_Heading" type="string" ormtype="string"/>
<cfproperty name="Department" column="Department" type="numeric" ormtype="int" />
<cfproperty name="boss" column="boss" type="string" ormtype="string" />
<cfproperty name="Room" column="Room" type="string" ormtype="string" />
<cfproperty name="Phone" column="Phone" type="string" ormtype="string" />
</cfcomponent>
【问题讨论】:
-
我已将您的代码从我的答案中取出,并将其弹出到您的问题中(这是它所属的地方)。
-
我会把
returntype拿走,或者只是将它设置为array并每天调用它。 CF 需要验证数组是否仅包含该类型。问题解决了。 -
没有真正“解决问题”@Henry:代码应该按原样工作,所以这里肯定有一些东西,简单地掩盖当前错误会导致有问题的情况在调用代码中冒泡,这对任何人都没有帮助。
-
@AdamCameron 我同意,但是摆脱该返回类型问题将向作者说明其背后的真正问题,这很可能是因为它是一个空数组,找到了 0 个实体。
标签: coldfusion runtime-error invoke cfc coldfusion-10