1

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.

rodrigoap
  • 7,405
  • 35
  • 46

2 Answers2

1
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

jitter
  • 53,475
  • 11
  • 111
  • 124
  • Thanks. I found a full example here: http://www.roseindia.net/javacertification/wsd-guide/saaj_apis.shtml – rodrigoap Nov 02 '09 at 16:12
0

you can avoid the cast:

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

}
remipod
  • 11,269
  • 1
  • 22
  • 25