2 Replies Latest reply on Mar 28, 2011 4:40 PM by joe_boy12

    how to stop the service execution

    joe_boy12

      hello,

       

      could be a dumb Qs - is there any quick start which explains how to terminate/stop the service and send the response back if errors happen in one of the service actions?

       

      Thanks

      Joe

        • 1. how to stop the service execution
          joe_boy12

          I think I figured out that by returning null in action classes or throwing

          ActionProcessingException can stop the service execution, then I can override the error handling code in @OnException method.

           

          I am trying to send back a custom XML reply to the client code (if something goes wrong) which invoked my service on HttpGateway lets say

          <response status="error">

               <errors>

                    <error code="X0001">SOMETHING BAD HAPPENED</error>

               </errors>

          </response>

           

          anybody has sample code?

           

          Thanks

          Joe

           

          • 2. how to stop the service execution
            joe_boy12

            is it possible to send custom XML response back to Http client in a method which is annotated with @OnException

             

            I have a sample code in an action which throws one business exception, it executes the the method also but doesnt send the custom XML back. here is the code. All I see is exception stack trace which caused this methd to execute....

             

            @OnException
            public void error( Message msg )
            {
            if( log.isInfoEnabled())
            {
              log.info("+++++++++++++++++++ In error() +++++++++++++ :: OUCH " + msg.getFault());
            }

            String error = "<fault code=\"111\" order_id=\"O1234567\"><cause desc=\"SOMETHING BAD HAPPENED\"/></fault>";
            msg.getBody().add(error);

            HttpResponse response = new HttpResponse(200);
            //HttpResponse response = HttpResponse.getResponse(msg); // throws NPE
            response.setContentType("text/xml");
            response.setEncoding("UTF-8");
            response.setResponse(msg);
            }