Originally posted by Nikhil Agrawal:
If any server-side handler throws the SOAPFaultException, a fault message will be generated and is send back to the client. On the server side the handleFault() methods of all the Handler's in the return path will be called..right?
Fault processing begins with the handleFault method of the server handler that threw the javax.xml.rpc.soap.SOAPFaultException in handleRequest and is then called on the handlers that have already processed the in-bound request
in reverse order. Any handlers that have yet to process the request won't. The contents of the original SOAPFaultException is mapped to a
SOAP Fault which can then be inspected and manipulated by each handleFault (unless one of the handleFaults returns false - effectively bypassing the remaining handlers).
See
Extend JAX-RPC Web services using SOAP headers If the exception thrown by a server handleRequest is a javax.xml.rpc.JAXRPCException the SOAP Fault is immediately sent back to the client - no other handlers get to see or process it.
javax.xml.rpc.soap.SOAPFaultException - one of the server's request handlers "failed" the request message, previously invoked handlers get a chance to add to the SOAPFault returned to the client unless one server handler short-circuits handleFault processing by returning false.
javax.xml.rpc.JAXRPCException - a server handler handleRequest has run into a problem that isn't directly related to the request message content - i.e. this is a server problem. There is nothing useful that the other handlers could add so the SOAP Fault is sent directly to the client.
When this message is received on the client side, client-side handler's handleRespone() method will be called or handleFault() method?
The SOAP Fault is processed by handleFault on the client side. (There is no other way to invoke handleFault on the client side. Client-side handlers shouldn't be throwing javax.xml.rpc.soap.SOAPFaultExceptions and javax.xml.rpc.JAXRPCException bypass all further handler processing).
If the client-side handler's handleRequest() method returns false, then the message will be short-circuted and a reply will be send back. So this reply will be Reply or a Fault. Can we generate a fault message for this case?
A client's handleRequest = false causes the current SOAP Request to become the SOAP Response and to be sent back up the chain through the handleResponse methods. So this is only appropriate if the handler "knows" what the response should be - it never lets the request get any further and replaces the request with the response before returning "false". This is a regular SOAP reponse, not a SOAP Fault.
You do not throw javax.xml.rpc.soap.SOAPFaultException on the client side. There shouldn't be any problems with your own requests or the server's responses. So if your client-side handler runs into a problem it should throw a javax.xml.rpc.JAXRPCException which bypasses all remaining handlers. As your "problem report" is already an exception on the client side there is no need to generate a SOAP Fault.
[ March 27, 2008: Message edited by: Peer Reynders ]