webservice客户端访问,服务端获取客户端ip地址。
import 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; }
时间: 2024-10-02 06:05:07