Discussions

XML & Web services: How to find out a client's IP address in a Web Service

  1. I use IBM WebSphere Application Developer to create a Web Service implemented as a Java bean in a Web project. WebSphere creates a servlet as the service endpoint. Now I want to get the client's calling IP address to validate the its access to the service. But the container shields off the servlet so I can not use getRemoteAddr() method from the ServletRequest object. Is there a way I can retrieve the IP address?

    Thanks
  2. I don't have a solution for IBM, but BEA Weblogic offers the web service context. From there you can get the remote ip. Websphere might offer something similar.
  3. I like the WEA solution better[ Go to top ]

    IBM WAS is turning me into a blind.
  4. Try using a servlet filter that is configured to filter path of the web service. There you will be able to get the ip of the client.
  5. IBM is hiding everything completely[ Go to top ]

    Thanks for your responses.

    It's the IBM implementation that prevents all this becoming possible. All you need to do in IBM solution is to create a Java Bean to implement all the business logic, then use the WebService wizzard to create a project based on the Bean class. All I can see in the project is my own Java Bean class - a regular Java class. And IBM has the nerve to declare my Java Bean class as a "Servlet". WebSpehere hides all the WebService functions completely from users - it has all the WebService functions developed inside, not a single function you know that it's out there. Only when it needs your business functions, it calls your Bean object to get them.

    In short, WAS has its WebService container entirely built in and not exposing a single interface or a function!!!


    Thanks
    Paul
  6. How about using SOAP Handlers and capturing IP address of client. I've tried this in weblogic, but it didn't work as expected. Not sure if IBM has any way. -Rao
  7. This message chain is a bit old, but I thought it would hurt to ask anyway. I am using WAS 6.1, but couldn't find a way to get the client's ip address. Did anyone find a solution to get client's IP address in a Websphere web service ? Thanks, Gul