0 Replies Latest reply on Jul 19, 2008 4:20 AM by stigbn

    Webservice error messages

    stigbn
      Hi All
      I am using a web service to feed my flex application with data. When exceptions occur in the web service, I only get some generic error message in my fault handler. I would like to be able to get information such as error messages from the web service exceptions propagated to my web service fault handlers in my Flex Application.

      My web service is .Net based/C# and it is used in my Flex app by importing the WSDL file of the service.

      Here is an example with some code snippets:

      The web service has a HelloWorld webmethod which throws an exception. This webservice is imported into my flex app using the Data->Import Webservice feature, which autogenerates the webserivce class I am using. When I call the webservice from Flex, the fault handler is called but it only contains some generic error message.

      Code snippets: The C# webservice method which throws an exception:
      [WebMethod]
      public string HelloWorld()
      {
      throw new Exception("Hello World Exception.");
      return "Hello World";
      }

      And here is how I call the webservice in my FIex App:

      private function btnTestWebserviceClicked(event:Event):void
      {
      var service:WebService = new WebService();
      service.addWebServiceFaultEventListener(faultHandler);
      service.addhelloWorldEventListener(webMethodDone);
      service.helloWorld();
      function webMethodDone(event:HelloWorldResultEvent):void
      {
      Alert.show("Done", "Done");
      }
      function faultHandler(event:FaultEvent):void
      {
      Alert.show(event.fault.faultString, "Error");
      }
      }

      The information I can get from the faultEvent passed to the fault handler does not contain the error string but only the generic "HTTP request error" error message, and not the “Hello World Error String” which was passed to the exception thrown in the webservice.

      So my question is: How can I get information from web service exceptions propagated to my fault handlers in Flex?

      Any help, advice or pointers to articles will be much appreciated.
      Best regards Stig Nielsson