users@glassfish.java.net

Re: Extracting Client IP address in EJB endpoint

From: <glassfish_at_javadesktop.org>
Date: Tue, 18 Sep 2007 07:58:17 PDT

Hi,

I've not tried it myself, but I believe this is what you want:

In your EJB:

1- Add member variable 'SessionContext ejbContext'
2- add implementation for setSessionContext method
3- in the set session, do the follwoing

   public void setSessionContext(SessionContext cntxt)
   {
     ejbContext = cntxt;
   }

4-in your function, do this
   public String helloWorld()
   {
          javax.xml.rpc.handler.soap.SOAPMessageContext msgCntxt = (SOAPMessageC
ontext)
          ejbContext .getMessageContext();

          String remoteAddress = (String)msgCtx.getProperty("REMOTE_ADDR");
          return remoteAddress;
   }

Kind regards
Tom
[Message sent by forum member 'tomf' (tomf)]

http://forums.java.net/jive/thread.jspa?messageID=235835