Hi Malintha, Which version of synapse are you using ?
If it is a released version, following code snippet will do. synCtx.setTo(null); synCtx.setResponse(true); Axis2Sender.sendBack(synCtx); But if you are using a pack build from truck which has passthrough transport, you need to build the message by calling RelayUtils,buildMessage() prior to above code snippet. On Tue, Oct 27, 2015 at 5:32 AM, Hiranya Jayathilaka <hiranya...@gmail.com> wrote: > You might have to clear the To header on MessageContext. > > > On Oct 20, 2015, at 9:14 PM, Malintha Amarasinghe < > malintha.pra...@gmail.com> wrote: > > Hi All, > > We are implementing a custom handler for an API (extending > AbstractHandler) such that it authenticates the client using incoming > request headers and gives a custom authentication failure message back to > the client when an authentication failure happens. We set the custom > fault envelope to the message context and send it back to the client like > below. > > messageContext.setEnvelope(*faultEnvelope*); > Axis2Sender.sendBack(messageContext); > > When but the problem we face is when the client give a POST request to the > API with a request body, this does not send the custom response back to the > client. Instead of that, it resend the same request payload sent by the > client back to him. > > Highly appreciate if you can suggest us a better way to solve this. > > Thank you. > *Malintha Amarasinghe,* > Undergraduate, > Dept.of Computer Science and Engineering, > University of Moratuwa. > > > -- > Hiranya Jayathilaka > Mayhem Lab/RACE Lab; > Dept. of Computer Science, UCSB; http://cs.ucsb.edu > E-mail: hira...@cs.ucsb.edu <hira...@wso2.com>; Mobile: +1 (805) 895-7443 > Blog: http://techfeast-hiranya.blogspot.com > > -- *Isuru Udana* Associate Technical Lead *; WSO2 Inc.; http://wso2.com <http://wso2.com>email: isud...@gmail.com <isud...@gmail.com> blog: http://mytecheye.blogspot.com/ <http://mytecheye.blogspot.com/>*