In jax-rs:
//injectIn jax-ws, we inject a different resource but it's almost the same.
@Context
private HttpServletRequest httpServletRequest;
public void serviceMethod() {
//get the ip
log.debug("IP=" + httpServletRequest.getRemoteAddr());
}
@Resource
private WebServiceContext wsContext;
public void serviceMethod() {
MessageContext mc = wsContext.getMessageContext();
HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
log.debug("IP=" + req.getRemoteAddr());
}
If you need help building jax-rs service here's how I'm doing things: http://czetsuya-tech.blogspot.com/2014/11/rest-testing-with-arquillian-in-jboss.html.
0 nhận xét:
Đăng nhận xét