This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
1. Handler Framework : Handlers work in the order in which they are declared in the xml file or in the order in which they are added in the HandlerResolver. But the order is for Outgoing messages and for Incoming the order is reversed .
2.On the Client side Handlers can be added using the HandlerReolver also.This cannot be done on the server side.
There is one more way to add Handlers on the Client side , by setting a chain directly on a BindingProvider
Sim Kim, Are you trying to ask a question or just listing some findings about the handlers? If you were just noting handler creation strategies, there are more ways than you listed:
1. You can create handler chain using wsdl customizations. Put the customizations in a separate customization file or insert customizations directly into the wsdl (I don't recommend messing with wsdl this way). Choose this option to configure handler chain in a top down service design.
2. You can also create a handler chain by specifying @HandlerChain (file="handler_filename.xml) annotation on web service implementation or on SEI. The file should specify the chain using the same syntax as that used in the wsdl customization. Choose this option to configure handler chain in a bottom up service design.
3. You can define a handler chain in sun-jaxws.xml deployment descriptor. Again, the syntax to specify the chain is same as the two options above. This choice is implementation specific and will have to be reconfigured when migrating to a different implementation (e.g. from Glassfish to WebSphere or vice versa). Choose this option to configure handler chain at the deployment time.
4. You can define a handler chain by adding it directly in the binding provider (the option you covered). This option can be used to add handler chain on the client side. This is a great way to set the chain dynamically. For example, on the client side, you can first determine which service to invoke and then set the chain for that service.
5. You can use HandlerResolver to set handler chain (another option you cover). This option automatically adds the handler chain on ALL newly created binding objects. From design perspective, choose this option when the chain for a given service is predetermined and you don't want every piece of client code to have the code for adding handler chains (just like you don't want to create Connection in every DAO). Also, if your team consists of junior developers and you don't want them to temper with handler configuration etc., you can provide some kind of factory which returns the service object with the chain preset on it using this method.
An interesting food for thought is to ask: What happens if the chain is being executed and a handler returns false or throws an exception? What will happen to the chain execution? Will the message become response if it was request? What if the message was already response? Section 9.3.2 of jax-ws specification has the answers.