Java Reference
In-Depth Information
//determine if the message is coming or going
Boolean outbound = (Boolean)
ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
//different file name for request and response
String msgFileName = "";
//auto-unbox
if (outbound) {
LOGGER.debug("Message is OUTBOUND");
msgFileName = "outMsg.xml";
} else {
LOGGER.debug("Message is INBOUND");
msgFileName = "inMsg.xml";
}
try {
//do business logic here. We'll just log msg to file
LOGGER.debug("Logging....\n");
String dirName = "/tmp";
File logFile = new File(dirName, msgFileName);
logFile.createNewFile();
FileOutputStream fos = new FileOutputStream(logFile);
ctx.getMessage().writeTo(fos);
fos.close();
LOGGER.debug("Log complete.");
} catch (SOAPException ex) {
LOGGER.error("SOAP Exception--", ex);
} catch (IOException ex) {
LOGGER.error("IO Exception--", ex);
}
LOGGER.debug("Exiting handler normally.");
//indicate that we want to continue processing
return true;
}
public boolean handleFault(SOAPMessageContext ctx) {
LOGGER.error("SOAP FAULT! Quitting.");
return false;
}
public void close(MessageContext ctx) {
LOGGER.debug("Closing handler.");
}
Search WWH ::




Custom Search