I do it inside a custom handler, the code of which is
package com.xxx.handler;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.axis2.AxisFault ;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.logging.Log ;
import org.apache.commons.logging.LogFactory;
public class GetRequestHandler extends AbstractHandler implements Handler {
private Log log = LogFactory.getLog(GetRequestHandler.class);
public void invoke(MessageContext msgContext) throws AxisFault {
Map propsMap = msgContext.getProperties();
if(propsMap.size() == 0) {
System.out.println("msgContext props map is empty !!! ");
}
Set propsSet = props.entrySet();
if(propsSet.size() == 0) {
System.out.println("msgContext props set is empty !!! ");
}
HttpServletRequest httpServletRequest = (HttpServletRequest) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if(httpServletRequest == null) {
System.out.println("httpServletRequest is null !!! ");
}
}
}
On 7/12/06, Bruno Negrao <[EMAIL PROTECTED]> wrote:
Hi,
from where did you obtain the msgContext object?
bruno
On 7/12/06, heikki <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm trying to retrieve the HttpServletRequest in a handler, through its
> MessageContext, like so
>
> HttpServletRequest httpServletRequest = (HttpServletRequest)
> msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST
> );
>
> However, running this, httpServletRequest was null. On further examination
> I looked at all the properties I could get from MessageContext, using this
> code
>
> Map propsMap = msgContext.getProperties();
> if(propsMap.size() == 0) {
> System.out.println("msgContext props map is empty !!! ");
> }
> Set propsSet = props.entrySet();
> if(propsSet.size() == 0) {
> System.out.println("msgContext props set is empty !!! ");
> }
>
> which put out this
>
> msgContext props map is empty !!!
> msgContext props set is empty !!!
>
> Apparently, I don't have any property in the MessageContext in the handler.
> Is this usual? Should I take some extra step somewhere along the line?
>
> My purpose of getting HttpServletRequest is to retrieve URL params from the
> HTTP GET request. Is there another way to do achieve this?
>
>
> thanks and regards,
> Heikki Doeleman
>
