JAVA 1.6 生成的webService 纯JAVA工程获取请求IP方法
在WebService 的发布的代理类:
@Resource
private WebServiceContext wsContext;
@WebMethod(exclude=true)
public String getClientIp(){
javax.xml.ws.handler.MessageContext mc = wsContext.getMessageContext();
com.sun.net.httpserver.HttpExchange exchange = (HttpExchange)mc.get("com.sun.xml.internal.ws.http.exchange");
InetSocketAddress isa = exchange.getRemoteAddress();
InetAddress address = isa.getAddress();
String hostAddress = address.getHostAddress();
return hostAddress;
}
Java WebService中获取客户端IP的方法实现
本文详细介绍了在Java WebService发布的代理类中如何通过特定方法获取客户端的IP地址,利用WebServiceContext和HttpExchange类实现了从消息上下文中提取远程IP地址的功能。
4806

被折叠的 条评论
为什么被折叠?



