Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Obtaining the client host from a webservice

Reply
Thread Tools

Obtaining the client host from a webservice

 
 
Roberto
Guest
Posts: n/a
 
      10-18-2004
Hi, I need to know, inside an Axis web service, the client request
hostname. I.E.:

Client Webservice (AXIS server)
Hostname 1 -----> Hostname 2

Inside the source of WebService (usually named as
WebServiceBindingImpl.java) I would like to know the hostname 1 of client.

Any idea?

Inviato da www.mynewsgate.net
 
Reply With Quote
 
 
 
 
Andy Flowers
Guest
Posts: n/a
 
      10-18-2004
Try this...

// first get the message context
MessageContext mc = MessageContext.getCurrentContext();

// then get the remote address from the current HTTP request directed at the
web service
String remote_client =
((javax.servlet.http.HttpServletRequest)mc.getProp erty(org.apache.axis.transport.http.HTTPConstants. MC_HTTP_SERVLETREQUEST)).getRemoteHost();

"Roberto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, I need to know, inside an Axis web service, the client request
> hostname. I.E.:
>
> Client Webservice (AXIS server)
> Hostname 1 -----> Hostname 2
>
> Inside the source of WebService (usually named as
> WebServiceBindingImpl.java) I would like to know the hostname 1 of client.
>
> Any idea?
>
> Inviato da www.mynewsgate.net



 
Reply With Quote
 
 
 
 
Roberto Milani 2002
Guest
Posts: n/a
 
      10-19-2004
"Andy Flowers" <(E-Mail Removed)> wrote in message news:<ZSPcd.265$(E-Mail Removed)>...
> Try this...
>
> // first get the message context
> MessageContext mc = MessageContext.getCurrentContext();
>
> // then get the remote address from the current HTTP request directed at the
> web service
> String remote_client =
> ((javax.servlet.http.HttpServletRequest)mc.getProp erty(org.apache.axis.transport.http.HTTPConstants. MC_HTTP_SERVLETREQUEST)).getRemoteHost();


mc.getProperty(org.apache.axis.transport.http.HTTP Constants.MC_HTTP_SERVLETREQUEST))

is NULL, so I cannot call getRemoteHost().

Then I tried:

Iterator i = mc.getPropertyNames();
while (i.hasNext()) {
String v = (String) i.next();
System.out.println (v + " = " + msg.getProperty(v));
}

and the output is:

home.dir = .
realpath = axis/services/EsempioService
jws.classDir = jwsClasses
attachments.directory = C:\Documents and Settings\manganelli\Local Settings\Temp
transport.url = http://andromeda:8080/axis/services/EsempioService
path = axis/services/EsempioService

any idea?
 
Reply With Quote
 
Andy Flowers
Guest
Posts: n/a
 
      11-02-2004
What version of AXIS are you using ?

I use version AXIS version 1.1, in conjunction with Tomcat 4.1, and have no
problems getting this property.

If you have a look at the source, AxisServlet.java (which you can get from
http://ws.apache.org/axis/download.cgi) you ill see that this property is
set in the doGet() handler of the AXIS servlet.

You could also use the source to debug what may be happening in your
scenario.

"Roberto Milani 2002" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Andy Flowers" <(E-Mail Removed)> wrote in message
> news:<ZSPcd.265$(E-Mail Removed)>...
>> Try this...
>>
>> // first get the message context
>> MessageContext mc = MessageContext.getCurrentContext();
>>
>> // then get the remote address from the current HTTP request directed at
>> the
>> web service
>> String remote_client =
>> ((javax.servlet.http.HttpServletRequest)mc.getProp erty(org.apache.axis.transport.http.HTTPConstants. MC_HTTP_SERVLETREQUEST)).getRemoteHost();

>
> mc.getProperty(org.apache.axis.transport.http.HTTP Constants.MC_HTTP_SERVLETREQUEST))
>
> is NULL, so I cannot call getRemoteHost().
>
> Then I tried:
>
> Iterator i = mc.getPropertyNames();
> while (i.hasNext()) {
> String v = (String) i.next();
> System.out.println (v + " = " + msg.getProperty(v));
> }
>
> and the output is:
>
> home.dir = .
> realpath = axis/services/EsempioService
> jws.classDir = jwsClasses
> attachments.directory = C:\Documents and Settings\manganelli\Local
> Settings\Temp
> transport.url = http://andromeda:8080/axis/services/EsempioService
> path = axis/services/EsempioService
>
> any idea?



 
Reply With Quote
 
hbasavar hbasavar is offline
Junior Member
Join Date: Mar 2010
Posts: 1
 
      03-26-2010
Thanks for this post. I was able to use the solution provided on Axis 2. I had to change the reference appropriately but works great. It returns IP address and that was what I wanted.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtaining ip address of client socket in ruby Victor Rosillo Ruby 2 11-24-2007 05:34 PM
obtaining client side IP Paul ASP General 6 05-19-2005 10:15 AM
Method for obtaining client display size? What-a-Tool ASP General 4 01-04-2005 11:19 AM
Obtaining element ID for client script kw ASP .Net Web Controls 0 08-23-2004 07:35 PM
PIX: how to allow 1 host from outside interface to access another host on the inside interface? jonnah Cisco 1 04-21-2004 02:26 PM



Advertisments