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