在soapMessageContext中获取"HttpServletRequest" - Axis Handler

emr*_*rah 5 axis servlets soaphandler

我试图在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)

JBA*_*JBA 0

请参阅这篇文章jax ws getting client ip以获得非常好的解释。看起来,如果想要拥有一个通用处理程序(在我的例子中是提取客户端证书),则需要为 EE 容器托管的 Web 服务和 SE 托管的容器实现相同的逻辑。