有谁知道怎么解决这个问题吗?
"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>发布于 2013-03-30 10:09:56
你没有给我们太多继续下去的机会!一个人可以说的就是“错误消息非常清楚地解释了可能的错误”。如果你发布一些代码,那么我们可以给你一个更好的想法。
但基本上,您的方法期望返回一个Contact对象数组,但这并不是您试图返回的内容。
如果您扩展您的问题以包含足够的信息来正确回答,我将更新答案以使其更全面……
更新1我仍然不能回答你的问题,但我可以在这个答案上建立一点。
在我看来,您的entityLoad()实际上并没有找到任何东西。您是否存储了任何联系人?
您可以将您的方法更改为如下所示:
<cffunction name="getAllContacts" returntype="ANY" access="remote">
<cfset var allContacts = entityload("Contacts")>
<cfdump var="#allContacts#">
<cfreturn allContacts>
</cffunction>然后调用该方法,看看它输出了什么。这应该会给你一个线索。
待续..。如果你是一名StackOverflow警察,请不要理它。我知道这还不是一个完整的答案,但当我们弄清楚这件事的时候,它会是的。我自己知道要做什么
https://stackoverflow.com/questions/15714065
复制相似问题