5
我試圖在AxisHandler的「handleMessage」方法中獲得「HttpServletRequest」。 My AxisHandler實現瞭如下代碼所示的「SOAPHandler」。在soapMessageContext中獲取「HttpServletRequest」 - Axis Handler
我需要在「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;
}