WebService CXF 获取请求IP

方法一:
@Resource(name = "org.apache.cxf.jaxws.context.WebServiceContextImpl")   
private WebServiceContext context;

HttpServletRequest httpRequest1 = (HttpServletRequest)context.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);

LogConsole.info("ip:" + httpRequest1.getRemoteAddr());


方法二:
Message message = PhaseInterceptorChain.getCurrentMessage();
HttpServletRequest httpRequest = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
LogConsole.info("ip:" + httpRequest.getRemoteAddr());

你可能感兴趣的:(webservice)