在AIR 中使用RemoteObject 调用Coldfusion对象的时候总是无法调用,用Alert把错误信息弹了出来,如下:
faultCode:Client.Error.MessageSend
faultString:'Send failed'
faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: : url:'http://yair.swf/'
服务器端用的是
Blazeds——Adobe做的一个开源的类似于FDS的东西,一开始百思不得其解啊,仔细检查了一下Blazeds的配置文件和RemoteObject的 destination属性也没有发现错误。无奈,只好Google之,虽然没有搜索到答案,但是发现别人写RemoteObject的时候用到了一个属性:endpoint,其实这个属性是在Blazeds 或者 FDS 的配置文件中是已经有默认定义的,一般都在 WEB-INF\flex\services-config.xml 中定义的,RemoteObject默认的信息传送channel是 “my-amf”,而在services-config.xml有如下定义:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"/>
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf” class="flex.messaging.endpoints.AMFEndpoint" />
blazeds用的是tomcat服务器,如果正常的话其实endpoint应该是 http://localhost:8400/samples/messagebroker/amf 的,但是不知道为什么,Flex Builder却自动把我的AIR endpoint默认为'http://yair.swf/',莫名其妙,于是自己在程序里定义了 RemoteObject 的 endpoint 属性,测试了一下,还是报错
[RPC Fault faultString="Unable to invoke CFC - The method sayHellow was not found in component myair.cfc.hw." faultCode="Server.Processing" faultDetail="For details, turn on Robust Exception Information in the ColdFusion Administrator"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:240]
at mx.rpc::Responder/fault()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at NetConnectionMessageResponder/statusHandler()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:569]
at mx.messaging::MessageResponder/status()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:222]
查了一下帮助文档,在 Language Reference 里面的对 RemoteObject 的 endpoint 属性解释后面有这么一句话:
Note: This property is required when creating AIR applications.
也就是说,AIR程序如果使用RemoteObject 的话就必须自己定义endpoint !
没有错,加上了!点解!!!
再Google两把,又说cfc未定义,爷不会犯这种低级错误,无果!
休息下冒个烟,搂了一眼错误日志!呀!!!是不会犯低级错误,但犯更低级的错误!该!
Unable to invoke CFC - The method sayHellow was not found in component myair.cfc.hw
总结:
总结:频繁保存会降低心理警惕,调错多看错误日志,每次报错未必一样,往往正确答案就在手边。长时间工作,劳逸结合方能保持清晰思维
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。