How to capture X-Forwarded-For (tRestRequest)

Seven Stars

How to capture X-Forwarded-For (tRestRequest)

Hi, I am using tRestRequest. I want to capture " X-Forwarded-For" parameter from the header of the incoming message.
When I am adding that parameter in tRestRequest, it does not allow me to do that. Please advise. Thank you.

 
Twelve Stars

Re: How to capture X-Forwarded-For (tRestRequest)

X-Forwarded-For

illegal name for column - Talend (Java) not accept some characters in names - "-", space and etc
-----------
Employee

Re: How to capture X-Forwarded-For (tRestRequest)

sorry, seems no chance. there is an issue with the same roots - https://jira.talendforge.org/browse/TESB-13797 - consider please vote for it.
Employee

Re: How to capture X-Forwarded-For (tRestRequest)

In meantime check request context properties such as "ALL_HEADER_PARAMS" and "ALL_QUERY_PARAMS"
thanks, Sergey
Employee

Re: How to capture X-Forwarded-For (tRestRequest)

yes, indeed!
thanks for the hint, Sergey!
forgot I already answered such question (even several times Smiley Happy).
so please try following way to retrieve the header in tJavaRow or tJavaFlex component right after tRESTRequest component:
((javax.ws.rs.core.MultivaluedMap<String, String>) ((java.util.Map<String, Object>) globalMap.get("restRequest")).get("ALL_HEADER_PARAMS")).getFirst("X-Forwarded-For")
Seven Stars

Re: How to capture X-Forwarded-For (tRestRequest)

yes, indeed!
thanks for the hint, Sergey!
forgot I already answered such question (even several times Smiley Happy).
so please try following way to retrieve the header in tJavaRow or tJavaFlex component right after tRESTRequest component:
((javax.ws.rs.core.MultivaluedMap<String, String>) ((java.util.Map<String, Object>) globalMap.get("restRequest")).get("ALL_HEADER_PARAMS")).getFirst("X-Forwarded-For")


Sergey, atelesh:
This works, Thank you.... 
Six Stars

Re: How to capture X-Forwarded-For (tRestRequest)

It could be really helpful if Talend has some facade pattern for this king of access either like:
InboundContext.getHeaders.getXForwardFor()
or 
InboundContext.getHeaders.get("Name")
I love the tree metadata information of the inbound and outbound contexts for example in Oracle Service Bus, here in Talend it is not that well organized and easily accessible.
Employee

Re: How to capture X-Forwarded-For (tRestRequest)

headers map can be easily exposed using component variables regular way in Studio.
(actually message context also - as more generic way)
Alex