Quantcast
Viewing all articles
Browse latest Browse all 9369

Re: How to get the consumer IP address : EJB exposed as web service

try with below code...

 

import javax.servlet.http.HttpServletRequest;

 

@GET

@Path("/yourservice")

@Produces("text/xml")

public void activate(@Context HttpServletRequest requestContext,@Context SecurityContext context){

   String yourIP = requestContext.getRemoteAddr().toString();

 

   //If security is enabled

   Principal principal = context.getUserPrincipal();

   String userName = principal.getName();

 

}

 

-----------------------------------------------------

 

private SessionContext sessionContext;

 

     public void setSessionContext(SessionContext context)

     {

          sessionContext = context;

     }

 

 

public void method()

{

javax.xml.rpc.handler.soap.SOAPMessageContext msgCntxt = (SOAPMessageContext)sessionContext.getMessageContext();

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

}


Viewing all articles
Browse latest Browse all 9369

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>