1 Reply Latest reply on Oct 22, 2007 7:24 AM by Peter Farland

    Handling exceptions thrown by ASP.NET web services

    JoshBeall Level 1
      Hello all,

      I am using Flex Builder 3.0 Milestone 3 Beta 2 (build 3.0.183158).

      I have an ASP.NET web service that can throw exceptions. Here's an example of the SOAP XML that gets sent back to the client when an exception is thrown (along with an HTTP 500).

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Invalid or missing SOAP header credentials ---&gt; Invalid credentials</faultstring>
      <faultactor> http://webdev1/MiscellaneousWebUtilities/RENotice/RENotice.asmx</faultactor>
      <detail />
      </soap:Fault>
      </soap:Body>
      </soap:Envelope>

      Now, when I handle the FaultEvent in ActionScript, here's what the event contains:

      evt mx.rpc.events.FaultEvent (@6c0a301)
      bubbles true
      cancelable true
      currentTarget mx.rpc.AsyncToken (@6c83fa1)
      eventPhase 2
      message null
      messageId null
      target mx.rpc.AsyncToken (@6c83fa1)
      token null
      type "fault"
      fault mx.rpc.Fault (@77fe3d1)
      errorID 0
      message "faultCode:Server.Error.Request faultString:'HTTP request error' faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://webdev1/MiscellaneousWebUtilities/RENotice/RENotice.asmx" URL: http://webdev1/MiscellaneousWebUtilities/RENotice/RENotice.asmx'"

      name "Error"
      faultCode "Server.Error.Request"
      faultDetail "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://webdev1/MiscellaneousWebUtilities/RENotice/RENotice.asmx" URL: http://webdev1/MiscellaneousWebUtilities/RENotice/RENotice.asmx"

      faultString "HTTP request error"
      rootCause null
      headers null

      As you can see, there's not really anything there to indicate the exception that was thrown -- in particular, I'd like to be able to get at the exception message, which is "Invalid or missing SOAP header credentials ---> Invalid credentials". But that doesn't appear anywhere in the FaultEvent.

      I suppose this is rather a feature request -- but I was curious how others have handled this?

      -Josh
        • 1. Re: Handling exceptions thrown by ASP.NET web services
          Peter Farland Level 3
          Due to limitations in the browser's plug-in API that is exposed to the Flash Player, for non-200 HTTP response status codes, the response body is not made available to the Flash Player and thus your SOAP fault cannot be found. You'll need to work on getting the HTTP response to be a 200 while still returning the SOAP response Fault body. One method to achieve this is to use the Proxy Service in LCDS.