Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am sing TalendESB --> tRestRequest. I am able to see all the content of globalMap.get("restRequest").
{URI_ABSOLUTE=http://localhost:8088/data/, PATTERN=/data/, OPERATION=b, ALL_HEADER_PARAMS={a=[123], Accept=[application/json, text/plain, */*], accept-encoding=[gzip, deflate, br], Accept-Language=[en-US,en;q=0.8], connection=[keep-alive], Content-Length=[9], content-type=[application/x-www-form-urlencoded], DNT=[1], h1=[header1], Host=[localhost:8088], User-Agent=[Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36]}, VERB=POST, MESSAGE_CONTEXT=org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext@29b4f161, URI_BASE=http://localhost:8088/, CorrelationID=null, PARAMS={HEADER:h1:id_String=header1, FORM:q1:id_String=mydata}, URI=data/, ALL_QUERY_PARAMS={}, URI_REQUEST=http://localhost:8088/data/}
I specifically need to extract the PARAMS object...
PARAMS={HEADER:h1:id_String=header1, FORM:q1:id_String=mydata}
How can I capture the HEADERS and FORM data in tJavaRow (after tRestRequest)?
Thanks!
OK, what I thought would work, does work. You will need a bit of Java experience for this, but with that you should be able to extrapolate from the code below which will print out
//The object with the key "restRequest" is a HashMap
java.util.Map<String, Object> myMap = ((java.util.Map<String, Object>)globalMap.get("restRequest"));
//Print out of what you are seeing already
System.out.println("MyMap = " +myMap.toString());
//Create an iterator over the keyset
java.util.Iterator<String> it = myMap.keySet().iterator();
//Iterate over the keyset and print out the keys
while(it.hasNext()){
System.out.println(it.next());
}
//Retrieve the PARAMS HashMap
java.util.Map<String, Object> myParams = ((java.util.Map<String, Object>)myMap.get("PARAMS"));
//Create an Iterator for the PARAMS HashMap
java.util.Iterator<String> it2 = myParams.keySet().iterator();
//Iterate over the PARAMS HasMap
while(it2.hasNext()){
System.out.println(it2.next());
}
EDIT: My reply was not relevant after re-looking at you question. I'll be back after trying something
OK, what I thought would work, does work. You will need a bit of Java experience for this, but with that you should be able to extrapolate from the code below which will print out
//The object with the key "restRequest" is a HashMap
java.util.Map<String, Object> myMap = ((java.util.Map<String, Object>)globalMap.get("restRequest"));
//Print out of what you are seeing already
System.out.println("MyMap = " +myMap.toString());
//Create an iterator over the keyset
java.util.Iterator<String> it = myMap.keySet().iterator();
//Iterate over the keyset and print out the keys
while(it.hasNext()){
System.out.println(it.next());
}
//Retrieve the PARAMS HashMap
java.util.Map<String, Object> myParams = ((java.util.Map<String, Object>)myMap.get("PARAMS"));
//Create an Iterator for the PARAMS HashMap
java.util.Iterator<String> it2 = myParams.keySet().iterator();
//Iterate over the PARAMS HasMap
while(it2.hasNext()){
System.out.println(it2.next());
}
Glad it worked ...or helped you to get to a working solution 🙂
Hi,
Do you really need to handle this restRequest global variable ?
I did test below:
1-My job looks like:
With:
In my tJavaRow, I can get these two fields:
System.out.println(globalMap.get("restRequest"));
System.out.println("********************H1******************************");
System.out.println(input_row.h1);
System.out.println("********************Q1******************************");
System.out.println(input_row.q1);
2-I call this REST webservice from SOAPUI:
3-Then I get the values of these two parameters (As they are in the global variable):
{URI_ABSOLUTE=http://localhost:8088/TEST, PATTERN=/, OPERATION=OUT, ALL_HEADER_PARAMS={accept-encoding=[gzip,deflate], connection=[keep-alive], Content-Length=[9], content-type=[application/x-www-form-urlencoded], h1=[header1], Host=[localhost:8088], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}, VERB=POST, MESSAGE_CONTEXT=org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext@1f3cbb32, URI_BASE=http://localhost:8088/TEST, CorrelationID=null, PARAMS={HEADER:h1:id_String=header1, FORM:q1:id_String=mydata}, URI=/, ALL_QUERY_PARAMS={}, URI_REQUEST=http://localhost:8088/TEST}
********************H1******************************
header1
********************Q1******************************
mydata
Doesn't it meet your requirements ?
Eric
I can use these; and I am doing so. But there are some places in my code where I simply need to ignore the calls and log them. I do not want to parse the headers and all. Hence, when I found this restRequest GlobalMap, it struck me as I can simply dump this info directly for now and parse it later as needed.
Thanks!