[RPC Fault faultString="Error #2070

本文分享了一位开发者在使用 Flex3 开发 RIA 应用过程中遇到的一个关于从同一目录加载 XML 文件的安全沙箱错误。通过详细分析错误日志和检查 XML 文件格式,最终定位到问题是由于 XML 文件格式不正确导致的。
I’m in the process of developing a new Flex 3 RIA, and the server code is not yet written, so I’m using static XML files to provide data while I build out the UI functionality. The XML files are stored on my development machine in a subdirectory of the folder that holds the main SWF. It’s all a very standard setup, and I was successfully loading two files from the same subdirectory, so I was very surprised this morning when I got a security sandbox error:

Error #2070: Security sandbox violation:
caller cannot access Stage owned by .
As implied by the reference to “Stage owned by”, this error is supposed to occur when you are loading a SWF from an unauthorized domain. I did some quick searching on Google, and everything I looked at had to do with loading a SWF. The stack trace did not clarify the issue either:

[RPC Fault faultString="Error #2070: Security sandbox
violation:caller cannot access Stage owned by ."
faultCode="Client.CouldNotDecode" faultDetail="null"]
at mx.rpc.http::HTTPService/http://www.adobe.com/
2006/flex/mx/internal::processResult()
[E:\dev \3.0.x\frameworks\projects\rpc\src\mx\rpc\http
\HTTPService.as:842]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/
mx/internal::resultHandler()
[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\
AbstractInvoker.as:186]
at mx.rpc::Responder/result()[E:\dev\3.0.x\frameworks\
projects\rpc\src\mx\rpc\Responder.as:41]
at mx.rpc::AsyncRequest/acknowledge()
[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\
AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()
[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\
messaging\channels\DirectHTTPChannel.as:381]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I suspected something was wrong with the XML file, since the UI was successfully loading other files from the same directory. I opened the file in XML Spy, which immediately displayed a message to the effect that the XML was not well-formed. And sure enough, I had missed something. Here is what the XML looked like:

<page>
<name>page1</name>
<type>pagetype</type>
<previewUrl>previewUrl</previewUrl>
<path>page/path1</path>
<promoTypes>
</promoType>typeOne</promoType>
</promoType>typeN</promoType>
</promoTypes>
</page>
You will probably see the error right away, but to my embarrassment I didn’t. How did the error creep in? Well, I had copied the sample XML from the design document (which I did not write) and pasted it into an XML file so that I’d have something to pull in for development purposes, and evidently I did not check it over very carefully. (If you don’t see the error, look closely at the promoType tags, and you’ll see that the opening tags have closing slashes.)

I fixed the XML, the error vanished, and I was able to resume forward progress. Clearly, the error message displayed by the debug player was not only non-helpful, it was actually misleading.

I thought I’d post this here in case anyone else runs into a similar problem. It may save you a few minutes of wonderment.
visit url:http://hi.baidu.com/zcq100/blog/item/de12ec1f93f85b69f724e434.html
对以下代码解释import pandas as pd import chardet from pathlib import Path import numpy as np # ====================== # 配置参数 # ====================== DATA_PATH = r"C:\Users\huang\Desktop\1112W\Charging_Data.csv" # 原始数据路径 OUTPUT_PATH = r"C:\Users\huang\Desktop\1112W\cleaned_charging_data.csv" # 清洗后数据保存路径 # ====================== # 辅助函数 # ====================== def detect_file_encoding(file_path): """自动检测文件编码""" with open(file_path, &#39;rb&#39;) as f: result = chardet.detect(f.read()) return result[&#39;encoding&#39;] def safe_parse_dates(df, date_columns): """安全解析日期列""" for col in date_columns: if col in df.columns: df[col] = pd.to_datetime(df[col], errors=&#39;coerce&#39;) return df # ====================== # 主处理流程 # ====================== try: # 1. 读取数据(自动检测编码) encoding = detect_file_encoding(DATA_PATH) df = pd.read_csv( DATA_PATH, encoding=encoding, engine=&#39;python&#39; ) # 2. 标准化列名(处理前后空格/大小写) df.columns = df.columns.str.strip().str.lower() # 3. 解析时间列 time_columns = [&#39;start time&#39;, &#39;end time&#39;] df = safe_parse_dates(df, time_columns) # 4. 计算充电时长(小时) df[&#39;duration&#39;] = (df[&#39;end time&#39;] - df[&#39;start time&#39;]).dt.total_seconds() / 3600 # 5. 数据清洗逻辑 # (1) 过滤无效充电记录(功率为0且属于故障) fault_conditions = ( (df[&#39;transaction power&#39;] == 0) & ( df[&#39;is_ev_fault&#39;].astype(int) | df[&#39;is_abnormal&#39;].astype(int) | df[&#39;is_system_issue&#39;].astype(int) ).astype(bool) ) valid_df = df[~fault_conditions].copy() # (2) 处理时间异常 # 过滤负时间差 time_anomaly = valid_df[valid_df[&#39;duration&#39;] < 0] if not time_anomaly.empty: print(f"发现时间异常记录 {len(time_anomaly)} 条,已自动过滤") valid_df = valid_df[valid_df[&#39;duration&#39;] >= 0] # (3) 去除极端值(超过7天的充电记录) valid_df = valid_df[valid_df[&#39;duration&#39;] <= 168] # 6. 保存清洗后数据 valid_df.to_csv(OUTPUT_PATH, index=False) print(f"数据清洗完成,有效记录数: {len(valid_df)}") print(f"清洗后数据已保存至: {OUTPUT_PATH}") except FileNotFoundError: print(f"错误:文件 {DATA_PATH} 未找到") except KeyError as e: print(f"列名错误:{str(e)} 不存在于数据文件中") except Exception as e: print(f"处理过程中发生未预期错误: {str(e)}")
06-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值