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