Heikki,

Let me try to provide you with a solution, try it out and let me know.
This is more of a hack in my opinion, but it will get the job done.

I assume that you have your own handler inserted into the Handler chain.
You can use messageContext.setPause(true) which will pause the execution flow in the handler chain and exit.

So if the validation fails then do the following steps

a) Create a new Msg Context with what ever message you want to send

b) create an AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());

c) do msgContext.setPause(true) on the old msgContext

so here is the code for your Handlers invoke method

public void invoke(MessageContext msgContext) throws AxisFault{

     // do your validations

    if ( validation failed ){
    
        MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
        outMsgContext.getOperationContext().addMessageContext(outMsgContext);
  
        SOAPEnvelope envelope // create the SOAP envelope and fill in with your custom msg with validation errors or whatever info
        outMsgContext.setEnvelope(envelope);

        AxisEngine engine =
                new AxisEngine(
                        msgContext.getOperationContext().getServiceContext().getConfigurationContext());

        engine.send(outMsgContext);
 
       msgContext.setPause(true); // so this will stop the execution of the handler chain
   }
}








On 8/1/06, heikki < [EMAIL PROTECTED]> wrote:
>
>
>
>
> >
> >
> > Hi there,
> >
> > === Davanum Srinivas asked me to repost this on the dev list :
> >
> > a previous posting of mine on this (on the Axis2 user's list),  from about two weeks ago was left unanswered that's why I'll give it another try :
> >
> > I would like to know whether it is possible to to stop a handler chain, in the middle, and return a response from the last handler that executed, WITHOUT throwing an AxisFault or other exception.
> >
> > For example, I have a handler doing some validation and when validation fails, I don't want to continue; but I also don't want to throw up: what I want to do is return a custom "normal" response, which maybe describes the validation failures, but is not in any way an "error" response.
> >
> > In a servlet filter chain this is very easy to do, but I haven't figured it out in a Axis2 handler chain. Can anyone help me?
> >
> > thanks and regards
> >
> > Heikki Doeleman    
>
>  

Reply via email to