<em id="hanht"></em>

    <dd id="hanht"></dd>

    <em id="hanht"><acronym id="hanht"></acronym></em>
    
    <button id="hanht"></button>
    <rp id="hanht"><object id="hanht"><blockquote id="hanht"></blockquote></object></rp><em id="hanht"></em>

    首頁 > 設計 > WEB開發 > 正文

    21.3.處理Web Services異常

    2023-08-14 18:53:58
    字體:
    來源:轉載
    供稿:網友
    問題
    我該如何處理web service引發的異常呢.
    解決辦法
    監聽fault 事件
    討論
    當web services 引發異常時,方法會發出fault事件,類型為mx.rpc.events.FaultEvent,下面的代碼注冊了fault 事件處理函數:
    +展開
    -ActionScript
    webService.addEventListener(FaultEvent.FAULT, onWebServiceFault);

    FaultEvent 類定義了一個fault屬性,類型為mx.rpc.Fault. Fault 對象返回有關異常的信息,包含如faultCode, faultDetail, faultString, 和rootCause 屬性,下面的例子用Alert 顯示異常信息:
    +展開
    -ActionScript
    private onWebServiceFault(event:FaultEvent):void {
    var fault:Fault = FaultEvent.fault;
    var message:String = "An error occurred. The details are as follows/ncode: " + fault.faultCode;
    message += "/ndetail: " + faul.faultDetail;
    Alert.show("Web Service Error", message);
    }
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表