How To Become The Client's Ip Address Inwards Jax Rs Together With Ws

In this tutorial I'll non learn how to employ jax-rs nor jax-ws spider web service only rather volition demo how nosotros tin cash inward one's chips the client's or the caller's ip address who invoke the service.

In jax-rs:
//inject @Context someone HttpServletRequest httpServletRequest;  world void serviceMethod() {  //get the ip  log.debug("IP=" + httpServletRequest.getRemoteAddr()); } 
In jax-ws, nosotros inject a dissimilar resources only it's nearly the same.
 @Resource someone WebServiceContext wsContext;  world void serviceMethod() {   MessageContext mc = wsContext.getMessageContext();  HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);   log.debug("IP=" + req.getRemoteAddr()); } 

If you lot require help edifice jax-rs service here's how I'm doing things: https://ngeblognow.blogspot.com//search?q=rest-testing-with-arquillian-in-jboss.
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.