I developed a java class with an only method and turned into web service (JBOSS) using JBossWS. I would like to get the IP address of the client who started the request. (I'm not using jsp)
public String getMyIP() {
//get IP from client from current request
// return IP as String
}
Thanks!
Solved!
First set this resource in the class:
@Resource
WebServiceContext wsContext;
Then use this code on your class:
SOAPMessageContext jaxwsContext = (SOAPMessageContext)wsContext.getMessageContext();
HttpServletRequest request = HttpServletRequest)jaxwsContext.get(SOAPMessageContext.SERVLET_REQUEST);
String ipAddress = request.getRemoteAddr();