Java Reference
In-Depth Information
Note Jim White's “Working with Headers in JAX-WS SOAPHandlers” blog post
( http://www.intertech.com/Blog/post/Working-with-Headers-
in-JAX-WS-SOAPHandlers.aspx ) demonstrates the usefulness of getHead-
ers() .
The overriding close() method does nothing because there are no resources that
need to be cleaned up. In contrast, handleFault() and handleMessage() in-
voke the private log() method to log a SOAP message.
The log() methodusesits SOAPMessageContext argumenttoobtainthevalue
of the property identified as MessageCon-
text.MESSAGE_OUTBOUND_PROPERTY . The return value determines whether an
Inbound message stringoran Outbound message stringislogged. log() next
usesthisargumenttoinvokethe SOAPMessage getMessage() method,whichre-
turnsa SOAPMessage objectwhose write(Object o) methodiscalled towrite
the SOAP message to the stream identified by out .
Youneedtoinstantiate thisclass andaddtheresulting instance totheclient's orthe
webservice'shandlerchain.Usethe @HandlerChain annotationtoaddthishandler
toawebservice'shandlerchain.Incontrast, Listing11-20 revealstheprogrammaticap-
proach to adding a handler to a client's handler chain.
Listing 11-20. Adding a SOAPHandler instance to a client's handler chain
import java.net.URL;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import javax.xml.ws.handler.Handler;
import ca.tutortutor.tv.TempVerter;
class TempVerterClient
Search WWH ::




Custom Search