Java Reference
In-Depth Information
public MultipleHandlerResolver() {
chain = new ArrayList<Handler>();
chain.add(new SetVersionHandler());
chain.add(new VersionInstructionsHandler());
}
//...
This resolver defines one handler that will set the version that the client is using into the
message context. Another handler is defined to add additional instructions to the outgoing
SOAP message given a certain client version. The handler that modifies the message context
is shown in Example 6-13 .
Example6-13.SetVersionHandler.java
package com.soacookbook.ch03.handler;
import static java.lang.System.out;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.log4j.Logger;
public class SetVersionHandler implements
SOAPHandler<SOAPMessageContext> {
private static final Logger LOGGER =
Logger.getLogger(SetVersionHandler.class);
public boolean handleMessage(SOAPMessageContext ctx) {
LOGGER.debug("Handling SOAP MESSAGE.");
//determine if the message is coming or going
f inal Boolean outbound = (Boolean)
ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound){
ctx.put("SVC-VERSION", "1.0");
}
return true;
}
public boolean handleFault(SOAPMessageContext ctx) {
LOGGER.error("SOAP FAULT! Handle here...");
Search WWH ::




Custom Search