Hi,

You should try the same syntax but in your calling method (not in the init() ).


package myWebService;

import org.apache.axis2.context.MessageContext;

public class MyService {
public String giveYourIp(){
    MessageContext msgCtx =  MessageContext.getCurrentMessageContext();
    return (String)msgCtx.getProperty(MessageContext.REMOTE_ADDR); 
}
}


Tony.

From: [email protected]
To: [email protected]
Date: Fri, 1 Jul 2011 17:45:26 +0100
Subject: RE: Identify IP address of the source request








Nadir,
 
How to get msgContext obj.
I am 
using:
MessageContext msgCtx =  
MessageContext.getCurrentMessageContext();
 
But msgCtx is null.


From: Nadir Amra [mailto:[email protected]] 

Sent: 30 June 2011 21:59
To: 
[email protected]
Cc: 
'[email protected]'
Subject: RE: Identify IP address of the 
source request


How about trying something like: 


(String)msgContext.getProperty(MessageContext.REMOTE_ADDR); 


Nadir Amra
Integrated Web Services for 
IBM i Operating System
Internet: [email protected] 

"Matta, Geethamadhurima " <[email protected]> wrote on 
06/30/2011 03:52:58 PM:

> From: "Matta, Geethamadhurima " 
<[email protected]> 
> To: 
"'[email protected]'" <[email protected]> 

> Date: 06/30/2011 03:53 PM 
> Subject: RE: Identify IP address of the source request 

> 
> Deepal,
> 
> Following is the 
code:
> ---------------------------
> public void 
init(ServiceContext serviceContext) {
>           
      System.out.println("Initializing the service 
context");
>                 
MessageContext msgCtx = 
> 
MessageContext.getCurrentMessageContext();
>         
        if (msgCtx != null)
>       
          {
>           
              String remoteAddress 
=(String)
> msgCtx.getProperty("REMOTE_ADDR");
>     
                    
System.out.println("remoteAddress - " + 
> remoteAddress);
>   
              }
>       
  }
> ---------------------------
> 
> msgCtx is coming 
as null.
> 
> 
> 
> Regards,
> Geeta 
Madhurima
> Desk: (212) 723 2505
> -----Original 
Message-----
> From: Deepal Jayasinghe [mailto:[email protected]]
> Sent: 
30 June 2011 20:41
> To: [email protected]
> Subject: Re: 
Identify IP address of the source request
> 
> You can get the 
remote IP address of the client corresponding to the
> current message as 
follows; String remoteAddress =
> 
String)msgCtx.getProperty("REMOTE_ADDR"):
> 
> Deepal
> 

> On Thu, Jun 30, 2011 at 3:34 PM, Matta, Geethamadhurima 
> 
<[email protected]> wrote:
> > Hi,
> 
>
> > I am using Axis2 1.5.1.
> >
> > We need to 
authenticate if the request coming to Axis2 server is 
> from a valid 
source.
> > Can we identify using the ip address of the source.
> 
> Is there any way to get the ip address of the source from the 
request?
> >
> > Regards,
> > Geeta Madhurima
> 
> Desk: (212) 723 2505
> >
> > 
---------------------------------------------------------------------
> 
> To unsubscribe, e-mail: [email protected]
> > 
For additional commands, e-mail: [email protected]
> 
>
> >
> 
> 
> 
> --
> http://blogs.deepal.org
> 
> 
---------------------------------------------------------------------
> To 
unsubscribe, e-mail: [email protected]
> For 
additional commands, e-mail: [email protected]
> 
> 

> 
---------------------------------------------------------------------
> To 
unsubscribe, e-mail: [email protected]
> For 
additional commands, e-mail: [email protected]
> 

                                          

Reply via email to