How to change the response soap message in javax.xml.rpc.handler.Handler.handleFault(MessageContext ctx)

StackOverflow https://stackoverflow.com/questions/1652612

  •  22-07-2019
  •  | 
  •  

Question

I wrote a handler (javax.xml.rpc.handler.Handler) for a SOAP web service that inspects header data. How can I modify the response message when the method handleFault is invoked?

public class SeguridadHandler implements javax.xml.rpc.handler.Handler {
    ...
    public boolean handleFault(MessageContext context) {
        // modify the response message here
        return true;
    }
    ...

}

Thanks.

Was it helpful?

Solution

public boolean handleFault(MessageContext context) {
    SOAPMessageContext smc = (SOAPMessageContext) context;
}

Cast to SOAPMessageContext and then do whatever you want. Depending on what exactly you need to do also consider using MessageFactory

OTHER TIPS

you can avoid the cast:

public class SeguridadHandler implements SOAPHandler<SOAPMessageContext> {
    ...
    public boolean handleFault(SOAPMessageContext context) {
        // modify the response message here
        return true;
    }
    ...

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top