Java Reference
In-Depth Information
return false;
}
public void close(MessageContext ctx) {
LOGGER.debug("Closing handler.");
}
public Set<QName> getHeaders() {
return null;
}
}
The handler here simply adds a string key/value pair to the message context. That key can be
used by other handlers in the chain to retrieve the value. Note that you only set the version
metadata if the message is outbound.
NOTE
Recall that handlers are invoked in the order specified in the resolver when outgoing, and in the re-
verse order when inbound. Logical handlers are always called before protocol handlers.
Now the next handler in the chain is invoked before the message is dispatched. It specifies
instructions for the service if a certain version is in use, and adds them to an attachment to the
outbound message, as shown in Example 6-14 .
Example6-14.Returning binary data from a web service
public class VersionInstructionsHandler implements
SOAPHandler<SOAPMessageContext> {
public boolean handleMessage(SOAPMessageContext ctx) {
LOGGER.debug("Handling SOAP MESSAGE.");
//determine if the message is coming or going
final Boolean outbound = (Boolean)
ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
//is message incoming?
if (outbound) {
//get the version from context
final String version = (String)ctx.get("SVC-VERSION");
LOGGER.debug("Service Version: " + version);
Search WWH ::




Custom Search