在flex应用程序上的IE跨域过滤器

时间:2010-01-22 02:36:44

标签: flex3

我有一个使用flex表单来捕获用户输入的应用程序。当用户输入表单数据(包括绘图区域)时,应用程序创建表单的jpg图像并发送回服务器。由于数据敏感,因此必须使用https。此外,客户端要求将表单的jpg和pdf版本存储在服务器上。

应用程序分三步发送数据

1 - 使用ordernumber发送jpg快照

2 - 将表单数据字段作为发布数据发送,使其在地址栏中不可见

3 - 发送pdf数据

我首先使用urlloader发送jpg数据并在执行操作2和3之前等待服务器响应,以确保服务器已创建与新orderNumber关联的记录。

此代码在IE中通过http工作正常。但是,如果我尝试通过https使用该应用程序,IE会阻止来自商店jpg步骤的页面响应,并且urlloader的完整事件永远不会触发。该应用程序在FireFox上通过http或https正常工作。

这是crossdomain.xml(我用“”替换了域名):

<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">

<cross-domain-policy>

  <allow-access-from domain="*.<mydomain>.com" to-ports="*" secure="false"/>
  <allow-http-request-headers-from domain="*.<mydomain>.com" headers="*">

</cross-domain-policy> 

以下是用户按下提交按钮时执行的代码:

private function loaderCompleteHandler(event:Event):void {

            sendPDF();
            sendPatientData();
        }


        private function submitOrder(pEvt:MouseEvent):void
        {
            //disable submit form so the order can't be submitted twice
            formIsValid = false;
            waitVisible = true;

            //submit the jpg image first with the order number, userID, provID
            //and order type.  The receiveing asp will create the new order record
            //and save the jpg file.  jpg MUST be sent first.
            orderNum = userID + "." + provID + "." + Date().toString() + "." + orderType;

            var jpgURL:String = "https://orders.mydomain.com/orderSubmit.asp?sub=jpg&userID=" + userID + "&provID=" + provID + "&oNum=" + orderNum + "&oType=" + orderType;

            var jpgSource:BitmapData = new BitmapData (vbxPrint.width, vbxPrint.height);
            jpgSource.draw(vbxPrint);
            var jpgEncoder:JPEGEncoder = new JPEGEncoder(100);
            var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);

            var header:URLRequestHeader = new URLRequestHeader ("content-type", "application/octet-stream");

            //Make sure to use the correct path to jpg_encoder_download.php
            var jpgURLRequest:URLRequest = new URLRequest (jpgURL);     
            jpgURLRequest.requestHeaders.push(header);              
            jpgURLRequest.method = URLRequestMethod.POST;               
            jpgURLRequest.data = jpgStream;

            //navigateToURL(jpgURLRequest, "_blank");

            var  jpgURLLoader:URLLoader = new URLLoader();

            try
            {
                jpgURLLoader.load(jpgURLRequest);
            }
            catch (error:ArgumentError)
            {
                trace("An ArgumentError has occurred.");
            }
            catch (error:SecurityError)
            {
                trace("A SecurityError has occurred.");
            }

            jpgURLLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler);

        }


        private function sendPatientData ():void
        {
            var dataURL:String = "https://orders.mydomain.com/orderSubmit.asp?sub=data&oNum=" + orderNum + "&oType=" + orderType;

            //Make sure to use the correct path to jpg_encoder_download.php
            var dataURLRequest:URLRequest = new URLRequest (dataURL);       
            dataURLRequest.method = URLRequestMethod.POST;
            var dataUrlVariables:URLVariables = new URLVariables(); 

            dataUrlVariables.userID = userID
            dataUrlVariables.provID = provID
            dataUrlVariables.name = txtPatientName.text
            dataUrlVariables.dob = txtDOB.text
            dataUrlVariables.contact = txtPatientContact.text
            dataUrlVariables.sex=txtSex.text
            dataUrlVariables.ind=txtIndications.text

            dataURLRequest.data = dataUrlVariables
            navigateToURL(dataURLRequest, "_self");     

        }

        private function sendPDF():void
        {
            var url:String = "https://orders.mydomain.com/pdfOrderForm.asp"
            var fileName:String = "orderPDF.pdf&sub=pdf&oNum=" + orderNum + "&oType=" + orderType + "&f=2&t=1" + "&mid=" + ModuleID.toString()
            var jpgSource:BitmapData = new BitmapData (vbxPrint.width, vbxPrint.height);
            jpgSource.draw(vbxPrint);
            var jpgEncoder:JPEGEncoder = new JPEGEncoder(100);
            var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);

            myPDF = new PDF( Orientation.LANDSCAPE,Unit.INCHES,Size.LETTER);
            myPDF.addPage(); 
            myPDF.addImageStream(jpgStream,0,0, 0, 0, 1,ResizeMode.FIT_TO_PAGE );
            myPDF.save(Method.REMOTE,url,Download.ATTACHMENT,fileName);

        }

目标asp页面不会发回任何数据,但基本网站页面模板除外。

任何人都可以帮我弄清楚如何解决这个IE跨域问题吗?我已经关闭了IE工具安全设置中的XSS过滤器,但仍然无法解决问题。

感谢

1 个答案:

答案 0 :(得分:1)

通过https执行所有操作。从https网址加载swf。通过https发送初始表单帖子。通过https发送图像。