0

I've been looking through the WebLogic API and can't seem to find what I'm looking for... Is there a way to determine at run-time the URL being used by an application to access a web service? I have a requirement to log the URL/protocol that was used on every incoming request to the server.

Any insight is much appreciated. Thanks!

Kal

Kal
  • 185
  • 3
  • 12

1 Answers1

3

The below should work on Weblogic (servlet container).

You need to get the HttpServletRequest and you can access any of the methods of HttpServletRequest.

I've used a JAX-RS example via the @Context, but the principle should be the same for your web service call.

@GET
@Produces("text/plain")
public String showFullURL(@Context HttpServletRequest hsr) {
   return hsr.getRequestURL();
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
JoseK
  • 31,141
  • 14
  • 104
  • 131
  • Sorry, I'm not sure how this would work. I'd like to do the logging in a handler (filter) before the actual service is invoked. Also, I can't find an equivalent of getRequestURL in the message context. It doesn't seem to have the same methods as an HttpServletRequest. – Kal Jul 20 '10 at 13:36
  • For accessing methods via message context see here: http://stackoverflow.com/questions/133436/how-can-i-get-access-to-the-httpservletrequest-object-when-using-java-web-service. – JoseK Jul 20 '10 at 13:42
  • Thanks so much! I was able to get exactly what I needed from your example and the link you gave me. Thanks again! – Kal Jul 20 '10 at 17:28