protected boolean handleInbound(MessageContext ctx)
{
Endpoint endpoint = EndpointAssociation.getEndpoint();
if (endpoint != null && isRecording(endpoint))
{
Record record = RecordFactory.newRecord();
RecordGroupAssociation.pushGroupID(record.getGroupID());
record.setDate(new Date());
HttpServletRequest httpServletRequest = (HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST);
if (httpServletRequest != null)
{
try
{
record.setDestinationHost(new URL(httpServletRequest.getRequestURL().toString()).getHost());
record.setSourceHost(httpServletRequest.getRemoteHost());
}
catch (Exception e)
{
log.warn("Unable to read from the http servlet request! " + e.getMessage());
}
}
record.setHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_REQUEST_HEADERS)));
record.setMessageType(MessageType.INBOUND);
record.setOperation((QName)ctx.get(MessageContext.WSDL_OPERATION));
boolean processEnvelope = false;
for (Iterator<RecordProcessor> it = endpoint.getRecordProcessors().iterator(); it.hasNext() && !processEnvelope; )
{
processEnvelope = it.next().isProcessEnvelope();
}
if (processEnvelope) //skip message processing if not required since it's very time-consuming
{
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
try
{
SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
if (soapEnv != null)
{
record.setEnvelope(DOMWriter.printNode(soapEnv, true));
}
}
catch (SOAPException ex)
{
log.error("Cannot trace SOAPMessage", ex);