问题:在为CFC请求WSDL时,我收到以下错误:Variable FORM is undefined。它发生在这行代码中,在 application.cfc 的 OnRequestStart 方法中
<cfif structKeyExists(form,'resetappvars')>
<cfset OnApplicationStart() />
</cfif>
如果我请求特定的方法,它可以正常工作。如果不存在,我曾考虑使用 cfparam 创建默认表单结构,但这似乎是一个丑陋的 hack,我担心它实际上会在 CFC 的变量或此范围内创建表单结构。也许这也是一个合法的错误?
注意:这仅在我请求 WSDL 时发生,如果我直接调用一个方法 - 代码按预期执行而没有问题。
更新: Application.cfc 代码示例 - 只需将任何 CFC 添加到您的应用程序并请求它?wsdl
以查看问题。这已经在 ColdFusion 7 和 ColdFusion 8 上进行了测试(但失败了)。
<cfcomponent output="false">
<cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false" hint="Fires when the application is first created.">
<cfset application.dsn = "my_dsn" />
<cfreturn true />
</cffunction>
<cffunction name="OnRequestStart" access="public" returntype="boolean" output="false" hint="Fires at first part of page processing.">
<cfargument name="TargetPage" type="string" required="true" />
<cfif structKeyExists(form,'resetappvars')>
<cfset OnApplicationStart() />
</cfif>
<cfreturn true />
</cffunction>
</cfcomponent>