zoukankan      html  css  js  c++  java
  • flex HTTPService浅析

    HTTPService是一种前后台交互技术。

    用于获取后台返回数据或者传递参数给后台,后台经过处理返回数据。对于flex返回的数据经常用xml格式。

    这里有一个封装好的示例,正常加载返回方法resultFunction,异常返回方法faultFunction

    public function doRestCall(url:String, resultFunction:Function, faultFunction:Function=null, restMethod:String='GET', parms:Object=null):void
                {
                    var thttpService:HTTPService=new HTTPService();
                    thttpService.method=restMethod;
                    thttpService.url=url;
                    thttpService.resultFormat = 'e4x';
                    thttpService.addEventListener(ResultEvent.RESULT, resultFunction);
                    if (faultFunction != null)
                    {
                        thttpService.addEventListener(FaultEvent.FAULT, faultFunction);
                    }
                    thttpService.send(parms);
                    thttpService.disconnect();
                }

    restMethod:传递方式。

    parms:需要传递的参数。(有待后续研究)

    其实简易方式可以这样写:

    if(httpService==null)
                    {    
                        httpService=new HTTPService();
                        httpService.useProxy=false;
                        httpService.method="POST";
                        httpService.resultFormat="e4x";
                        httpService.addEventListener(ResultEvent.RESULT,ShowMsgResult);
                        httpService.addEventListener(FaultEvent.FAULT,httpFault);
                    }
                    httpService.url=UpLoadUrl+"?contractid="+contractno+"&pcid="+pcid+"&operate=delete&filefolder="+encodeURIComponent(path);
                    httpService.send();
  • 相关阅读:
    python基本数据类型
    大学排名之数据库练习
    Python turtle学习笔记
    初学爬虫
    用python进行对乒乓球的比赛分析,并且将该程序进行封装
    新网页
    Python pandas
    十大经典排序算法
    C++的split()函数
    C++多态意义探究
  • 原文地址:https://www.cnblogs.com/tiandi/p/2538875.html
Copyright © 2011-2022 走看看