my dog learned polymorphism*
The moose likes Web Services and the fly likes Local ip address and port number of WS client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Local ip address and port number of WS client" Watch "Local ip address and port number of WS client" New topic
Author

Local ip address and port number of WS client

Nils Kruemel
Greenhorn

Joined: Feb 19, 2011
Posts: 2
Hi!

I've created a WS client using wsimport. For my question you may refer to an example taken from http://www.javadb.com/create-a-web-service-client-with-jax-ws .
Here is the corresponding client code:




Well, my problem now is how can I get the LOCAL IP address and TCP port number that is used by the CLIENT when calling the web service? I need this information for logging purposes. There are several network interfaces attached. I managed to retrieve all exchanged SOAP messages with a handler but I think IP address and port number are not accessible in a SOAPMessageContext that is used there.

Any ideas? Thanks in advance.
Nils
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Can you adapt the service code for this? It can retrieve both the client IP and client port, and send those back as part of the response.


Ping & DNS - my free Android networking tools app
Nils Kruemel
Greenhorn

Joined: Feb 19, 2011
Posts: 2
Unfortunately, I have no influence on the web service. I have to find a way to do it with the client code.
It would be a shame if it is not possible to do it with the straightforward wsimport code generation since it is really easy to use.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Saying "it would be a shame" would be taking it rather far, IMO. This is arcane functionality that's not germane to web services (which are not wedded to any particular transport mechanism, after all).

If you dig deep into the WS client-side code (not the generated code - the source code of the SOAP stack you're using) you should be able to get at the Socket object being used; it can provide you with the local port and IP address.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Local ip address and port number of WS client
 
Similar Threads
Client problem for my JAX-WS web service
newbie question: wsimport not working
creating web service client
Confusion in writing web service client + jax-ws
How to create Web service using JAX-WS in Jboss