Capture Source Information

Seven Stars

Capture Source Information

Is there any quick and easy way to capture source request information (like IP address/ hostname/ client details/ and anything else) of the source calling the REST request? 
Employee

Re: Capture Source Information

This can probably be optionally captured by tRESTRequest and saved in the request context. The short term solution is to do, in Java,
HttpServletRequest req = (HttpServletRequest)org.apache.cxf.jaxrs.utils.JAXRSUtils.getCurrentMessage().get("HTTP.REQUEST");
and check the client info...
I'll open a minor new feature request in meantime
Cheers, Sergey
Seven Stars

Re: Capture Source Information

This can probably be optionally captured by tRESTRequest and saved in the request context. The short term solution is to do, in Java,
HttpServletRequest req = (HttpServletRequest)org.apache.cxf.jaxrs.utils.JAXRSUtils.getCurrentMessage().get("HTTP.REQUEST");
and check the client info...
I'll open a minor new feature request in meantime
Cheers, Sergey

Thank you Sergey. I think this would work in the interim. 
Seven Stars

Re: Capture Source Information

Sorry to bring up this old post.
This statement is not returning any client IP address. Any help is appreciated
HttpServletRequest req = (HttpServletRequest)org.apache.cxf.jaxrs.utils.JAXRSUtils.getCurrentMessage().get("HTTP.REQUEST"); 
Employee

Re: Capture Source Information

Seven Stars

Re: Capture Source Information

See http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getRemoteAddr()

Hi, That does not work for me. it says 
I used: 
HttpServletRequest req = (HttpServletRequest)org.apache.cxf.jaxrs.utils.JAXRSUtils.getCurrentMessage().getRemoteAddr();
System.out.println(req);

Error:
Execution failed : Job compile errors 
At least job "ac_mq" has a compile errors, please fix and export again.
Error Line: 1841
Detail Message: The method getRemoteAddr() is undefined for the type Message
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.
Job ac_mq ended at 13:28 23/02/2017.

Thanks
Seven Stars

Re: Capture Source Information

Any help please? Thank you.