5 Replies Latest reply on Feb 13, 2009 7:11 PM by Michael Borbor

    HELP PLEASE! Correctly reading ColdFusion exceptions in Flex

      For those who want me to post this in Data Services, I already did, but sadly there's no traffic there so it went unanswered.

      Ok, so I'm using mx:Webservices to access several CFCs. I am successful in all of them except the one that throws an exception.
      Every time I process that exception (through my fault handler in flex) I get a generic IO Error.

      Here's the webservice code

      <mx:WebService id="cfc_Client"
      useProxy="false"
      wsdl=" http://xxx.xxx.xxx.xxx/_xxx/cfc_Client.cfc?wsdl"
      showBusyCursor="true">
      <mx:operation name="fncFlexCFTester" result="resultHandler(event)" fault="customFaultHandler(event)"/>
      </mx:WebService>

      and here's my CFC

      <cffunction name="fncFlexCFTester" access="remote" returntype="string">
      <cfargument name="boolFlag" type="boolean" required="true">

      <cfparam name="strHelloWorld" default="">
      <cfset strHelloWorld = "Hello World.">

      <cfif boolFlag>
      <cfreturn #strHelloWorld#>
      <cfelse>
      <cfthrow detail="CFTHROW DETAIL" errorcode="123" extendedinfo="CFTHROW CUSTOM EXTENDED INFO" message="CFTHROW CUSTOM MESSAGE" type="CFTHROW_CUSTOM_TYPE">
      </cfif>

      <!---<cfif boolFlag>
      <cfreturn #strHelloWorld#>
      <cfelse>
      <cfset intInf = 10 / 0>
      </cfif>--->

      </cffunction>

      So basically, if I call 'send(true)' I get 'Hello World' (which works btw), and if I call 'send(false)' I get the generic IO error.

      This is a known problem with Flex 2; you cannot get the details of the exception when using Webservices only when using RemoteObjects. However, Adobe claims that it was fixed in Flex 3... um... no it wasn't. Cause I downloaded the trial of Flex 3 and still generic message.

      HELP ME. I'm about to throw my computer from the window.
        • 1. Re: HELP PLEASE! Correctly reading ColdFusion exceptions in Flex
          Peter Farland Level 3
          When you use CFTHROW, I'm guessing that the HTTP response is sent back using a non-200 HTTP status code, such as 500. You could confirm by using an HTTP sniffer such as Paros Proxy or Charles and watch what is sent back to the client before it reaches the player.

          If this were the case, the plugin API exposed by the browser to the Flash Player does not provide the body of the response and thus Flash, and then hence Flex's WebService, does not know the nature of the failure, i.e. doesn't have access to the SOAP fault, so it can't give you any more information.

          The work around is to either get the server to use 200 as the HTTP response code but still include the SOAP fault in the response body (which will still be interpreted as a fault in Flex), or direct your request through a BlazeDS proxy-service destination which automatically takes care of this for you.
          1 person found this helpful
          • 2. Re: HELP PLEASE! Correctly reading ColdFusion exceptions in Flex
            matt_chotin Level 3
            Another workaround if you're in control of the CFC but maybe not the server would be to have the CFC not throw an error but instead return something that can be parsed by your web service result handler as an error.

            Yet another alternative would be to use RemoteObject instead of WebService :-)

            Finally, if you're using IE and Flash Player 10 along with the Flex 3.2 SDK the error will get propagated correctly, that's why we mention the bug as fixed. Other browsers still need to catch up with the work that we provided to them.
            • 3. Re: HELP PLEASE! Correctly reading ColdFusion exceptions in Flex
              quote:

              Originally posted by: pete
              When you use CFTHROW, I'm guessing that the HTTP response is sent back using a non-200 HTTP status code, such as 500. You could confirm by using an HTTP sniffer such as Paros Proxy or Charles and watch what is sent back to the client before it reaches the player.

              If this were the case, the plugin API exposed by the browser to the Flash Player does not provide the body of the response and thus Flash, and then hence Flex's WebService, does not know the nature of the failure, i.e. doesn't have access to the SOAP fault, so it can't give you any more information.

              The work around is to either get the server to use 200 as the HTTP response code but still include the SOAP fault in the response body (which will still be interpreted as a fault in Flex), or direct your request through a BlazeDS proxy-service destination which automatically takes care of this for you.



              Thanks Pete. Where would I go about doing the switch from 500 to 200. Is it through IIS? ColdFusion server? Pardon my ignorance, I'm a bit new to web programming.

              • 4. Re: HELP PLEASE! Correctly reading ColdFusion exceptions in Flex
                Peter Farland Level 3
                I'm not invovled with ColdFusion these days, but if you're not comfortable with the other work arounds suggested, perhaps you could try configuring a Java servlet filter in your CF web application's /WEB-INF/web.xml to modify HTTP status codes in responses from your ColdFusion based web service by adapting the approach mentioned here:

                http://stackoverflowexception.blogspot.com/2007/02/handing-web-service-exception-in-flex.h tml



                1 person found this helpful
                • 5. Re: HELP PLEASE! Correctly reading ColdFusion exceptions in Flex
                  Michael Borbor Level 4
                  Another possibility would be to use cflog and dump the error to a log file. To see what's going wrong with the WS call.

                  1 person found this helpful