Java Reference
In-Depth Information
Just like a servlet filter, the handler receives the request before the service does, allowing you
time to do some additional processing or massaging of the data.
Example 7-15 shows the implementation of the handler class.
Example7-15.LogHandler.java
package com.soacookbook;
import java.io.IOException;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.util.Set;
/**
* Logs inbound SOAP messages to the console.
*/
public class LogHandler
implements SOAPHandler<SOAPMessageContext> {
public Set<QName> getHeaders() {
System.out.println("LH: getHeaders");
return null;
}
public boolean handleMessage(SOAPMessageContext ctx) {
System.out.println("LH: handleMessage");
logToSystemOut(ctx);
return true;
}
public boolean handleFault(SOAPMessageContext ctx) {
System.out.println("LH: handleFault");
logToSystemOut(ctx);
return true;
}
// nothing to clean up
public void close(MessageContext messageContext) {
System.out.println("LH: close");
}
private void logToSystemOut(SOAPMessageContext ctx) {
System.out.println("LH: logToOut");
Search WWH ::




Custom Search