3 Replies Latest reply on Oct 18, 2007 9:52 AM by ntsiii

    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.

      Suggestions?