2008-10-24 92 views
0

我想從我的服務器獲取數據,使用RemoteObject來完成它。 當我在我的本地主機上運行應用程序時,它工作得很好,但是當我在我的服務器上使用它時,我得到一個Channel.Security.Error(訪問URL的安全錯誤)。RemoteObject - 跨域問題

在服務器端日誌中提到了跨域。 77.127.194.4 - [23/Oct/2008 21:15:11]「GET /crossdomain.xml HTTP/1.1」501

任何一個人遇到同樣的問題?任何想法 ?

回答

1

你試過添加到您的crossdomain.xml(在您取出由東西)這一點:

<?xml version="1.0"?> 
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/xml/dtds/cross-domain-policy.dtd"> 
    <cross-domain-policy> 
     <site-control permitted-cross-domain-policies="all"/> 
     <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" /> 
     <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" /> 
    </cross-domain-policy> 

的東西,在大寫鎖,你可能必須改變,以適應你的框架。例如,我從Macromedia Flash中使用的那個複製。而不是「www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/...」我通常有「www.macromedia.com/xml/dtds/...

我不知道,但試圖調查,這可能是你的問題。對於跨域,您通常需要添加到服務器端,其中您的fecthing的東西,從其他網站的權限獲得它。

1

我找到了解決方案。您是對的crossdomain.xml文件,但不幸的是,Python SimpleXMLRPCServer庫默認不支持GET方法,所以我們需要實現這一點。

from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler 

class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): 
    def do_GET(self): 
    #only allow a request for the crossdomain file 
    if self.path != '/crossdomain.xml': 
     self.send_response(403) 
     self.log_request(403) 
     return 

    #open the crossdomain file and read its contents 
    response = open('crossdomain.xml', 'r').read() 

    #write the data to the socket along with valid HTTP headers 
    self.send_response(200) 
    self.send_header("Content-type", "text/xml") 
    self.send_header("Content-length", str(len(response))) 
    self.end_headers() 
    self.wfile.write(response) 
    self.log_request(200)