Topic
  • 4 replies
  • Latest Post - ‏2012-03-30T16:09:43Z by SystemAdmin
joaocgf
joaocgf
3 Posts

Pinned topic Log web service caller ip address

‏2011-02-22T14:51:20Z |
Hi,

Im developing web services with WebSphere ESB and i need to log the ip address of the client making the call to the web services. I have created a custom logger in my mediations but i dont know i can i get the information i need.

Any help would be greatly appreciated

João
Updated on 2012-03-30T16:09:43Z at 2012-03-30T16:09:43Z by SystemAdmin
  • ultras
    ultras
    1 Post

    Re: Log web service caller ip address

    ‏2011-02-22T15:26:20Z  
    You can try creating a handler and associate it with your web service export (using the deployment editor). In the handler "handleRequest" method you can add something like context.getProperty("remoteaddr"). This should give you the IP address of the client.
  • mmalc
    mmalc
    74 Posts

    Re: Log web service caller ip address

    ‏2011-02-23T07:19:08Z  
    • ultras
    • ‏2011-02-22T15:26:20Z
    You can try creating a handler and associate it with your web service export (using the deployment editor). In the handler "handleRequest" method you can add something like context.getProperty("remoteaddr"). This should give you the IP address of the client.
    Take care if you come through some sort of a web proxy that the value you're getting is the value that you really want.

    Cheers
    marvin
  • joaocgf
    joaocgf
    3 Posts

    Re: Log web service caller ip address

    ‏2011-02-23T14:55:19Z  
    ultras pointed me in the right direction. I've created a handler for the webservice wich gave me acces to a context where i could extract the info i needed.

    public boolean handleMessage(SOAPMessageContext context) {
    WASAxis2HttpServletRequestImpl servletRequest =(WASAxis2HttpServletRequestImpl) context.get(MessageContext.SERVLET_REQUEST);

    ....

    }
  • SystemAdmin
    SystemAdmin
    289 Posts

    Re: Log web service caller ip address

    ‏2012-03-30T16:09:43Z  
    • joaocgf
    • ‏2011-02-23T14:55:19Z
    ultras pointed me in the right direction. I've created a handler for the webservice wich gave me acces to a context where i could extract the info i needed.

    public boolean handleMessage(SOAPMessageContext context) {
    WASAxis2HttpServletRequestImpl servletRequest =(WASAxis2HttpServletRequestImpl) context.get(MessageContext.SERVLET_REQUEST);

    ....

    }
    I am facing the same problem. Is it possible to get more detailed info how to do it?