①、 [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: 流错误。 URL: http://localhost:3000/posts/10.xml "]. URL: http://localhost:3000/posts/10.xml "]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
....................
这个大多是你的Ralis程序出错了,其实rails把error info全都发过来了,但是flex没法处理这些文本,于是出现上面的错误,这个时候你可以看看Rails控制台,那里显示了错误信息。不像以前rails的html页面编程时直接显示详细的出错信息。
②、 ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
...........................
以前在rails中,这个错误的解决方案有好几种,最佳方案是在页面中增加
<%= javascript_tag "var authenticity_token = '#{form_authenticity_token}';" %>
然后以隐藏字段post这个authenticity_token ,从而不破坏Rails的protect_from_forgery机制,但是现在要通过Rails向Flex传送authenticity_token ,我还没找到正解,只好暂时用下面的方法:
在Controller里添加:protect_from_forgery :except =>[:destroy,:update]
③、 [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP" ]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at DirectHTTPMessageResponder/securityErrorHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
那是因为 Flex 不使用代理时遇到安全沙箱冲突 。
解决方案:在../public目录下新建一个文件: crossdomain.xml
内容为:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
就OK了 ^_^
④、 / !\ FAILSAFE /!\ Thu Jul 16 14:50:31 +0800 2009
Status: 500 Internal Server Error
#<RuntimeError: attempted adding second root element to document>
c:/ruby/lib/ruby/1.8/rexml/document.rb:90:in `<<'
c:/ruby/lib/ruby/1.8/rexml/element.rb:867:in `add'
......................
script/server:3
...
attempted adding second root element to document
Line:
Position:
Last 80 unconsumed characters:
111111</password>
c:/ruby/lib/ruby/1.8/rexml/parsers/treeparser.rb:90:in `parse'
c:/ruby/lib/ruby/1.8/rexml/document.rb:204:in `build'
c:/ruby/lib/ruby/1.8/rexml/document.rb:42:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/xml_mini/rexml.rb:17:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/xml_mini/rexml.rb:17:in `parse'
(__DELEGATION__):2:in `__send__'
(__DELEGATION__):2:in `parse'
..............................
那是因为在<mx:HTTPService> 中设置了属性contentType="application/xml", 那么如果你通过以下方式 svcLogin .send( {login: loginTI.text, password: passwordTI.text} ); 发送request,就会出现上面的错误:又或者你写成
<mx:request>
<login>{loginTI.text}</login>
<password>{passwordTI.text}</password>
</mx:request>
也会出现同样的错误
因为xml方式发送参数格式应该是:只有一个root即<user>
<mx:request>
<user>
<login>{loginTI.text}</login>
<password>{passwordTI.text}</password>
</user>
</mx:request>
解决方案,就是去掉 contentType="application/xml", 那么<mx:HTTPService>就会采用默认的contentType="application/x-www-form-urlencoded", 那么
svcLogin .send( {login: loginTI.text, password: passwordTI.text} ); 就不会出错了。
⑤、 TabNavigator,Accordion组件 使浏览器地址出现类似字符串“#app= 6d4&68af-selectedIndex=1”
参考:http://hereson.iteye.com/blog/188513 得到解决方案:
在Flex Bulider中,右键点击项目,选Properties-->Flex Complier,将Enable integration with browser navigation 这个选项去除
Ps:本文持续更新中^_^