我有一个 SOAPHandler。我需要捕获响应的请求
public class SOAPLoggingHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleFault(SOAPMessageContext context) {
writeMessageLogging(context);
return true;
}
public boolean handleMessage(SOAPMessageContext context) {
writeMessageLogging(context);
return true;
}
private void writeMessageLogging(SOAPMessageContext smc) {
Boolean outboundProperty = (Boolean) smc
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (logger.isDebugEnabled()) {
if (outboundProperty.booleanValue()) {
logger.debug("Request message");
} else {
logger.debug("Response message:");
}
}
SOAPMessage message = smc.getMessage();
ByteArrayOutputStream out=null;
try {
if (!outboundProperty.booleanValue()) {
String requestXML="Request of the Response, is possible?";
}
out = new ByteArrayOutputStream();
message.writeTo(out);
String strMsg = new String(out.toByteArray());
logger.debug("strMsg:" + strMsg);
out.close();
} catch (Exception e) {
logger.error("Exception in handler:", e);
}finally{
IOUtils.closeQuietly(out);
}
}
}
看:
String requestXML="Request of the Response, is possible?";
是否可以在响应句柄中捕获请求?