You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Prashanth Narayanan <pr...@yahoo.com> on 2002/05/06 05:12:12 UTC

hostname of client machine?

hi all,
  is there any way to find the hostname of the machine
that is making the request to a webservice? iam using
apache2.2 on iplanet 6.0sp4.
  thanks,
  prash.

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

Re: hostname of client machine?

Posted by Virender Sandhu <vi...@m-trilogix.com>.
 Hi Prashanth

Refer to FAQs at apache soap
How can I get the IP address of a client that is using my SOAP Service?
If you add a SOAPContext Object as first Parameter in the signature of your
SOAP-service java-method, a 'SOAPContext' Object is passed to your class,
e.g.:
.mymethod(SOAPContext inContext, String inString)

This SOAPContext object gives you access to the HttpSession, HttpRequest,
HttpResponse (see java doc for details).
So, your SOAP service method can get the servlet request out of the context
object, and then call the getRemoteAddr() method on the service request
object:

import javax.servlet.http.*;
....
HttpServletRequest req =
(HttpServletRequest)soapCtx.getProperty(org.apache.soap.Constants.BAG_HTTPSE
RVLETREQUEST);
String remoteIPAddress = req.getRemoteAddr();

NOTE: this will only work where the client and server are both using the
Apache SOAP libraries.

----- Original Message -----
From: "Prashanth Narayanan" <pr...@yahoo.com>
To: <so...@xml.apache.org>
Sent: Sunday, May 05, 2002 11:12 PM
Subject: hostname of client machine?


> hi all,
>   is there any way to find the hostname of the machine
> that is making the request to a webservice? iam using
> apache2.2 on iplanet 6.0sp4.
>   thanks,
>   prash.
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>


Re: hostname of client machine?

Posted by Virender Sandhu <vi...@m-trilogix.com>.
 Hi Prashanth

Refer to FAQs at apache soap
How can I get the IP address of a client that is using my SOAP Service?
If you add a SOAPContext Object as first Parameter in the signature of your
SOAP-service java-method, a 'SOAPContext' Object is passed to your class,
e.g.:
.mymethod(SOAPContext inContext, String inString)

This SOAPContext object gives you access to the HttpSession, HttpRequest,
HttpResponse (see java doc for details).
So, your SOAP service method can get the servlet request out of the context
object, and then call the getRemoteAddr() method on the service request
object:

import javax.servlet.http.*;
....
HttpServletRequest req =
(HttpServletRequest)soapCtx.getProperty(org.apache.soap.Constants.BAG_HTTPSE
RVLETREQUEST);
String remoteIPAddress = req.getRemoteAddr();

NOTE: this will only work where the client and server are both using the
Apache SOAP libraries.

----- Original Message -----
From: "Prashanth Narayanan" <pr...@yahoo.com>
To: <so...@xml.apache.org>
Sent: Sunday, May 05, 2002 11:12 PM
Subject: hostname of client machine?


> hi all,
>   is there any way to find the hostname of the machine
> that is making the request to a webservice? iam using
> apache2.2 on iplanet 6.0sp4.
>   thanks,
>   prash.
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>