介紹Web Service取得client端ip
@Resource //宣告@Resource annotation
WebServiceContext wsContext; //宣告WebServiceContext物件
MessageContext mc = wsContext.getMessageContext();
HttpServletRequest request = //利用MessageContext取得request
(HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
//接著就可以使用request.getRemoteAddr()取得client的ip
String address = request.getRemoteAddr();
ps. 朋友介紹了取得透過proxy連線client的ip方法 http://www.blogjava.net/Alpha/archive/2006/07/12/57764.aspx
沒有留言:
張貼留言