Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to identify client calls from server side

 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we have a web service running in jboss as 4.2 and we have to check which client is accessing (just atleast one identity is enough). i.e. we there should be an indication that one client is accessing the web service in the console.

Is there any possibilities to get that client information form web service running console?
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Unless you enclose some information that helps you identify the client in requests to the server, I think the only piece of information giving information about the client is the IP address from which the request originates.
This is the "drawback" of web services - they are meant to be language and technology independent.
Best wishes!
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ivan,
Thanks for replying to my question. Atleast if I get that IPaddress or so information, thats enough to identify client.
Could you please give me a clue how to get that information.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Use the following procedure to be able to retrieve the IP address of the client, or the last proxy, form which the request was sent:
1. Have a WebServiceContext injected in the endpoint implementation class.
2. At request time, retrieve a MessageContext from the WebServiceContext.
3. From the MessageContext you can retrieve the servlet request object for the request using the MessageContext.SERVLET_REQUEST constant.
4. From the servlet request object you can retrieve the IP address using the ServletRequest.getRemoteAddress() method.
Best wishes!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic