views:

80

answers:

1

I have a java web service client that uses CXF. The server has 10+ possible ips that are resolved via dynamic dns. I have the jvm configured properly to not cache dns.

My question is, I have the requirement that I need to log on the client the payload with the ip it was delivered to. Logging just the hostname will not work as the hostname to ip resolution is constantly changing.

+1  A: 

I would suggest grabbing the source of the CXF LoggingInInterceptor from: http://svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java

and update it to suite your needs. Particularly, you would need to grab the HttpServletREquest off the message and figure out how to get the IP off of it to add to the logs. The CXF version is protocol agnostic (would work for JMS or others) and thus doesn't do any of the HTTP specific things that would require the HttpServletRequest.

Daniel Kulp
That would be on the server side, but I need it on the client side. I didn't make that clear in my question, so I have updated my question to reflect that. Sorry for the confusion!
Daniel Spivey
It would basically be the same answer, but grab the code for the LoggingOutInterceptor and grab the HttpURLConnection thing out of the message and grab what you can from it.
Daniel Kulp
I ended up getting the HttpURLConnection and then used reflection to access the private/protected members to get at the InetAddress object.HttpURLConnection httpUrlConnection = (HttpURLConnection)message.get("http.connection");use reflection for this...httpUrlConnection.delegate.http.serverSocket.inetAddressThanks for the help!
Daniel Spivey