webservice获取ip地址
2021-06-19 03:04
标签:服务端 XML nat request ring ipaddr let ipad log webservice客户端访问,服务端获取客户端ip地址。 webservice获取ip地址 标签:服务端 XML nat request ring ipaddr let ipad log 原文地址:http://www.cnblogs.com/ljl-blog/p/7194164.htmlimport javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import org.apache.cxf.jaxws.context.WebServiceContextImpl;
import javax.servlet.http.HttpServletRequest;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
public String getIpAddress() {
WebServiceContext context = new WebServiceContextImpl();
MessageContext ctx = context.getMessageContext();
HttpServletRequest request = (HttpServletRequest) ctx.get(AbstractHTTPDestination.HTTP_REQUEST);
String userIp = request.getRemoteAddr();
return userIp;
}