小编emr*_*rah的帖子

在soapMessageContext中获取"HttpServletRequest" - Axis Handler

我试图在AxisHandler的"handleMessage"方法中获得"HttpServletRequest".我的AxisHandler实现了"SOAPHandler",如下面的代码所示.

我需要在"InBoundDirection"中获得"HttpServletRequest",但它返回"null".

如何在SOAPHandler的"InBoundDirection"中获得"HttpServletRequest"?

谢谢..

@Override
public boolean handleMessage(SOAPMessageContext soapMessageContext) {
    boolean direction = ((Boolean) soapMessageContext.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue();        
    if (direction) {
        System.out.println("direction = outbound");
    } else {
        System.out.println("direction = inbound");
        HttpServletRequest servletReq=(HttpServletRequest) soapMessageContext.get(MessageContext.SERVLET_REQUEST);
        // BECAUSE servletReq is null the following line returns a "nullPointerException"
        System.out.println(servletReq.getRemoteHost()); 
    }
    return true;
}
Run Code Online (Sandbox Code Playgroud)

axis servlets soaphandler

5
推荐指数
1
解决办法
2398
查看次数

标签 统计

axis ×1

servlets ×1

soaphandler ×1