【问题标题】:Get IP address in JBoss Web Service在 JBoss Web 服务中获取 IP 地址
【发布时间】:2011-09-15 11:05:11
【问题描述】:

我开发了一个带有唯一方法的 java 类,并使用 JBossWS 变成了 Web 服务 (JBOSS)。我想获取发起请求的客户端的 IP 地址。 (我没有使用jsp)

public String getMyIP() {
  //get IP from client from current request
  // return IP as String
}

谢谢!

【问题讨论】:

标签: web-services jboss jbossws java-web-start


【解决方案1】:

解决了!

首先在类中设置这个资源:

@Resource
WebServiceContext wsContext;

然后在你的课堂上使用这个代码:

SOAPMessageContext jaxwsContext = (SOAPMessageContext)wsContext.getMessageContext();
HttpServletRequest request = HttpServletRequest)jaxwsContext.get(SOAPMessageContext.SERVLET_REQUEST);
String ipAddress = request.getRemoteAddr();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 2013-05-18
    • 2010-09-22
    相关资源
    最近更新 更多