Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tRESTRequest Header and building jobs

Hi,
I currently have a job which look like this :
  https://www.talendforge.org/forum/img/members/361125/capture_job.png
And i have some questions :  
- How can i get informations from the client (header of the Resquest, client IP, etc …) with tRESTRequest component ?
- Is it possible to make several jobs (with tRESTRequest on the same host) and still get only one war or jar ? Or i need to place all of the tRESTRequest on the same job ?
     For examples :
      in the first job named SO i have : tRESTRequest_1->Endpoint REST = /SO
      in the second job named IS i have : tRESTRequest_1->Endpoint REST = /IS

- As i see, Talend Studio use jetty server :


https://www.talendforge.org/forum/img/members/361125/capture_log4j.png
And i have seen that i can deploy the job on Talend Runtime (with the jar builded) but how can i deploy this job on tomcat ? (When i build my job he forced me to get a jar with OSGI Bundle, cause of tRESTRequest)
Regards, Csen
Labels (4)
3 Replies
Anonymous
Not applicable
Author

I definitely posted a reply this morning but it has not been persisted, may be I got it lost,
but what I typed was that all HTTP headers are available as a map on the request context, the property name is something like "ALL.HTTP.HEADERS" or similar. Another option is to add schema parameters and map them to individual HTTP headers (with a Comment field set to 'header', no quotes).
Sergey
Anonymous
Not applicable
Author

Thanks for the reply,

I tried to add one parameter (Host) with ‘header’ in comment column and “empty header” in default, and i tried to return the value with tJavaFlex : (tRESTRequest ? tJavaFlex)
main code :
        // try to get all headers
        System.out.println((context.getProperty("ALL_HEADER_PARAMS")));
        // try to get the host
        System.out.println((String)myRowName.Host);
the first row return null, the second return the host !

But i only have the host, what i want is to get all of the headers (Http-Method, Adress, …) like:
mars 15, 2016 4:47:14 PM org.apache.cxf.interceptor.LoggingInInterceptor

INFOS: Inbound Message
----------------------------
ID: 1
Address: http://<host>:<port>/<Uri>?<queryParameter1>=<value1>&<queryParameter2>=<value2>
Http-Method: GET
Content-Type:
Headers: {Accept=, accept-encoding=, Accept-Language=, Cache-Control=, connection=, Content-Type=, Host=, Upgrade-Insecure-Requests=, User-Agent=}
--------------------------------------

(i can’t add schema parameters named like ‘User-Agent’ cause of ‘-’)
I also want to get the client IP.

And i tried to get the response time from tRESTRequest to tRESTResponse (with tStatCatcher, tChronometerStart/Stop) but i can only returned the job execution time when i shutdown my job.
I always try to deploy my jobs on tomcat, but i will probably use Talend Runtime.
Thank you in advance,
Csen.
Anonymous
Not applicable
Author

Hi,
As i said before : context.getProperty("ALL_HEADER_PARAMS") is null.
But i found how to get request parameters (all headers params, URI, query params, ...),
I put this code in my tJavaFlex main code :
// return all request params
java.util.Map<String, java.util.Map<String, List<String>>> restReq =
(java.util.Map<String, java.util.Map<String, List<String>>>)globalMap.get("restRequest");
System.out.println(restReq);
// return all headers params
//java.util.Map<String, List<String>> headers = restReq.get("ALL_HEADER_PARAMS");
//System.out.println(headers);

and this give me something like :
{URI_ABSOLUTE=, PATTERN=/, 
OPERATION=getInfo,
ALL_HEADER_PARAMS={Accept=,
accept-encoding=, Accept-Language=,
Cache-Control=, connection=,
Content-Type=,
CorrelationID=,
Host=, User-Agent=, Via=, X-Forwarded-For=},
VERB=GET,
MESSAGE_CONTEXT=org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext@6060d0,
URI_BASE=,
CorrelationID=urn:uuid:d7285947-8bff-46e1-bd48-cf11504ebe56, PARAMS={},
URI=/, ALL_QUERY_PARAMS={id=, q=},
URI_REQUEST=}

I still need to deploy this job on tomcat,
Thanks again for your help,
Csen