axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xingshan He" <xingshan...@hotmail.com>
Subject RE: Could I get the client IP address in service or Handler class ?
Date Thu, 22 Jun 2006 18:09:35 GMT
Try this:

MessageContext messageContext =  MessageContext.getCurrentContext();
String ipAddress =
MessageContext.getStrProp(org.apache.axis.Constants.MC_REMOTE_ADDR);  


-----Original Message-----
From: Peter Feng [mailto:plf58@yahoo.com] 
Sent: Thursday, June 22, 2006 10:58 AM
To: axis-user@ws.apache.org
Subject: Re: Could I get the client IP address in service or Handler class ?

Perhaps you can check the Soap Envelope headers or Set
Soap Headers with this in your client code.

On the client side to set them if they don't exist in
your soap envelope already...
with automatically generated stubs:
ServiceWS port = service.getServiceWS();
			org.apache.axis.client.Stub s = (Stub)port;
		
s.setHeader("http://my.name.space/headers","clientIP","127.0.0.1");
						
on the server/handler side:
public void invoke(MessageContext msgContext) throws
AxisFault {
        try {
            System.out.println("Starting Server
verificationn");

            Message inMsg =
msgContext.getRequestMessage();
            Message outMsg =
msgContext.getResponseMessage();
						
            // verify signed message
						SOAPHeader
sh=inMsg.getSOAPHeader();
						SOAPHeaderElement she;
						System.out.println("get
inMsg soap header");
						Iterator
it=sh.examineAllHeaderElements();//"http://my.name.space/headers");
						while(it.hasNext()){
	
she=(SOAPHeaderElement)it.next();
	
System.out.println("examining soap header name
"+she.getNodeName()+" and val:"+she.getValue());
						}
				
Hope this helps.

--- � 軼(CEC) <s_itsu@cec-ltd.co.jp> wrote:

> hi all,
> 
> Could I get the client IP address in service class?
> or Handler's invoke()
> method ?
> 
> Any help or web resources would be greatly
> appreciated !
> 
> Regards,
> - sukie
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail:
> axis-user-help@ws.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message