How to get HTTPServletRequest object in Axis2

Posted on January 8, 2008

0


The following code demostrate how to get HTTPServletRequest object out of MessageContext in Axis2:

public static HttpServletRequest getHttpRequest() {
  return (HttpServletRequest) MessageContext.getCurrentMessageContext()
  .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
}

This is useful since from HTTPServletRequest we can call getRemoteUser() which returns basic authentication username provided by the client. Personally, the best way to do authentication is to use WSS4J (via Rampart plugin for Axis) which implements of WS-Security.

Posted in: Development