(HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
ServletContext con =
(ServletContext) objectModel.get(HttpEnvironment.HTTP_SERVLET_CONTEXT);
String soapAction = null;
MessageContext msgContext = null;
Message responseMsg = null;
try
{
res.setBufferSize(1024 * 8); // provide performance boost.
// Get message context w/ various properties set
msgContext = m_server.createMessageContext(req, res, con);
// Get request message
Message requestMsg =
new Message(
req.getInputStream(), false,
req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE),
req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION)
);
if (getLogger().isDebugEnabled())
{
getLogger().debug("Request message:\n" + messageToString(requestMsg));
}
// Set the request(incoming) message field in the context
msgContext.setRequestMessage(requestMsg);
try
{
//
// Save the SOAPAction header in the MessageContext bag.
// This will be used to tell the Axis Engine which service
// is being invoked. This will save us the trouble of
// having to parse the Request message - although we will
// need to double-check later on that the SOAPAction header
// does in fact match the URI in the body.
// (is this last stmt true??? (I don't think so - Glen))
//
soapAction = getSoapAction(req);
if (soapAction != null)
{
msgContext.setUseSOAPAction(true);
msgContext.setSOAPActionURI(soapAction);
}
// Create a Session wrapper for the HTTP session.
msgContext.setSession(new AxisHttpSession(req));
// Invoke the Axis engine...
if(getLogger().isDebugEnabled())
{
getLogger().debug("Invoking Axis Engine");
}
m_server.invoke(msgContext);
if(getLogger().isDebugEnabled())
{
getLogger().debug("Return from Axis Engine");
}
responseMsg = msgContext.getResponseMessage();
}
catch (AxisFault e)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Axis Fault", e);
}
// It's been suggested that a lack of SOAPAction
// should produce some other error code (in the 400s)...
int status = getHttpServletResponseStatus(e);
if (status == HttpServletResponse.SC_UNAUTHORIZED)
{
res.setHeader("WWW-Authenticate","Basic realm=\"AXIS\"");
}
res.setStatus(status);
responseMsg = new Message(e);
}
catch (Exception e)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Error during SOAP call", e);
}
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
responseMsg = new Message(AxisFault.makeFault(e));
}
}
catch (AxisFault fault)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Axis fault occured while perforing request", fault);
}
responseMsg = new Message(fault);
}
catch (Exception e)
{
throw new ProcessingException("Exception thrown while performing request", e);
}
// Send response back
if (responseMsg != null)
{
if (getLogger().isDebugEnabled())
{
getLogger().debug("Sending response:\n" + messageToString(responseMsg));
}
sendResponse(getProtocolVersion(req), msgContext.getSOAPConstants(), res, responseMsg);
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("AxisRPCReader.generate() complete");