<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [resolved] Reference header element in cHTTP in a Route in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233328#M23028</link>
    <description>Hi Ben, 
&lt;BR /&gt;Thank you for your response. So far, I'm happy with the Processor, even if no so elegant as a SetHeader component, but at least I have the URL of the endpoint separated in the cHTTP, and I can externalise it in the context easily. 
&lt;BR /&gt;EDIT: I realise that your solution (2 setHeader) was the first option I tested, and it never worked. I believe this is an error that has been solved in more recent versions of Talend (or Camel component?). I am using the version 5.1.2 which is starting to be a bit out of date. 
&lt;BR /&gt;I take the opportunity, to ask you about another problem, still related with cHTTP. I want to manage if I have an error in this HTTP call, because I want to send a special reply to the requester of the route. 
&lt;BR /&gt;I put the param "throwExceptionOnFailure=false" found on the Jetty Camel component, but my requester receives this response: 
&lt;BR /&gt; 
&lt;FONT color="blue"&gt;&lt;BR /&gt;java.net.ConnectException: Connection refused: connect&lt;BR /&gt; at java.net.DualStackPlainSocketImpl.connect0(Native Method)&lt;BR /&gt; at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.PlainSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.SocksSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt; at java.net.Socket.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt; at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)&lt;BR /&gt; at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)&lt;BR /&gt; at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)&lt;BR /&gt; at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)&lt;BR /&gt; at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)&lt;BR /&gt; at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)&lt;BR /&gt;&lt;/FONT&gt; 
&lt;BR /&gt;I would like to be able to analyse the response, and if it's connection refused, error 4XX or 5XX, handle it and send special response 
&lt;BR /&gt;Also, I try with a cTry and catch branch, but the route does not compile (see 2nd attached screenshot on my first post of the topic). Here is the code who does not compile 
&lt;BR /&gt; 
&lt;PRE&gt;								.to(uriMap.get("to Intermediate")).id(&lt;BR /&gt;										"cMessagingEndpoint_14").when().xpath(&lt;BR /&gt;										"/OrderStatus/Status='FINAL'")&lt;BR /&gt;								.to(uriMap.get("to Final")).id(&lt;BR /&gt;										"cMessagingEndpoint_11").doCatch(&lt;BR /&gt;										java.lang.Throwable.class).process(&lt;BR /&gt;										new org.apache.camel.Processor() {&lt;/PRE&gt; 
&lt;BR /&gt;The error displayed is 
&lt;BR /&gt; 
&lt;FONT color="red"&gt;The method doCatch(Class&amp;lt;Throwable&amp;gt;) is undefined for the type ChoiceDefinition&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Any ideas/suggestions? The version of Talend I'm using is 5.1.2.r90681 Professional Edition 
&lt;BR /&gt;Best regards, 
&lt;BR /&gt;Enrique</description>
    <pubDate>Thu, 21 Nov 2013 12:10:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-11-21T12:10:36Z</dc:date>
    <item>
      <title>[resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233325#M23025</link>
      <description>Hello, 
&lt;BR /&gt;I have a route with a cSetHeader which sets something in the header exchange. 
&lt;BR /&gt;I've validated that there is something there with the following Java code 
&lt;BR /&gt; 
&lt;FONT color="blue"&gt;&lt;BR /&gt;exchange.getIn().getHeader("test");&lt;BR /&gt;System.out.println("header: " + list.item(0).getTextContent());&lt;BR /&gt;&lt;/FONT&gt; 
&lt;BR /&gt;Now I try to use this header as a parameter in my external HTTP call (see cHTTP screenshot), but the variable is not replaced by its value. Instead I get this 
&lt;BR /&gt;GET /hlEndpoint/getStatus?orderNum=%24%7Bheader.newOrderId%7D HTTP/1.1 
&lt;BR /&gt;Any ideas? I can change this HTTP call to a POST if it makes it easier. 
&lt;BR /&gt;Regards, 
&lt;BR /&gt;Enrique 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MBHf.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155247i554CA3E8479CA2E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MBHf.png" alt="0683p000009MBHf.png" /&gt;&lt;/span&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MBkW.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139270i1FE11C49807ED452/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MBkW.png" alt="0683p000009MBkW.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Sat, 16 Nov 2024 11:50:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233325#M23025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T11:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233326#M23026</link>
      <description>Hello, 
&lt;BR /&gt;I succeed solving the problem, so I give the solution if it's helpful for somebody: 
&lt;BR /&gt;Before the cHTTP, put a Processor and put in Java 
&lt;BR /&gt; 
&lt;FONT color="blue"&gt;&lt;BR /&gt;com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList list = (com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList) exchange.getIn().getHeader("orderNumber");&lt;BR /&gt;String orderNumber = list.item(0).getTextContent();&lt;BR /&gt;exchange.getIn().setHeader(org.apache.camel.Exchange.HTTP_QUERY, "orderNumber=" + orderNumber);&lt;BR /&gt;&lt;/FONT&gt; 
&lt;BR /&gt;After, there is no need to put this as param in cHTTP component 
&lt;BR /&gt;Best regards, 
&lt;BR /&gt;Enrique</description>
      <pubDate>Tue, 19 Nov 2013 09:39:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233326#M23026</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-19T09:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233327#M23027</link>
      <description>Hi Enrique, 
&lt;BR /&gt;That should indeed work. If you'd like to accomplish this without using cProcessor, you could use a single cSetHeader component and include two entries. In the first, you can use some XPath to pull your order number out of the XML and place it in the first header (e.g. 'my_order_number'). Then in the second entry, you can use the Camel Simple language to build your HTTP query. In this case it would be "orderNumber=${header.my_order_number}". 
&lt;BR /&gt;I've included an example where I've done this with the entire HTTP URL, but it should easily apply to just the query portion like you're doing. 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;A href="http://camel.apache.org/simple.html" rel="nofollow noopener noreferrer"&gt;http://camel.apache.org/simple.html&lt;/A&gt; 
&lt;BR /&gt;Best Regards, 
&lt;BR /&gt;Ben 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MBkb.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/138796i8732C1E66544B23E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MBkb.jpg" alt="0683p000009MBkb.jpg" /&gt;&lt;/span&gt;</description>
      <pubDate>Tue, 19 Nov 2013 15:40:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233327#M23027</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-19T15:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233328#M23028</link>
      <description>Hi Ben, 
&lt;BR /&gt;Thank you for your response. So far, I'm happy with the Processor, even if no so elegant as a SetHeader component, but at least I have the URL of the endpoint separated in the cHTTP, and I can externalise it in the context easily. 
&lt;BR /&gt;EDIT: I realise that your solution (2 setHeader) was the first option I tested, and it never worked. I believe this is an error that has been solved in more recent versions of Talend (or Camel component?). I am using the version 5.1.2 which is starting to be a bit out of date. 
&lt;BR /&gt;I take the opportunity, to ask you about another problem, still related with cHTTP. I want to manage if I have an error in this HTTP call, because I want to send a special reply to the requester of the route. 
&lt;BR /&gt;I put the param "throwExceptionOnFailure=false" found on the Jetty Camel component, but my requester receives this response: 
&lt;BR /&gt; 
&lt;FONT color="blue"&gt;&lt;BR /&gt;java.net.ConnectException: Connection refused: connect&lt;BR /&gt; at java.net.DualStackPlainSocketImpl.connect0(Native Method)&lt;BR /&gt; at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)&lt;BR /&gt; at java.net.AbstractPlainSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.PlainSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.SocksSocketImpl.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.connect(Unknown Source)&lt;BR /&gt; at java.net.Socket.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt; at java.net.Socket.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt; at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)&lt;BR /&gt; at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)&lt;BR /&gt; at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)&lt;BR /&gt; at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)&lt;BR /&gt; at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)&lt;BR /&gt; at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)&lt;BR /&gt;&lt;/FONT&gt; 
&lt;BR /&gt;I would like to be able to analyse the response, and if it's connection refused, error 4XX or 5XX, handle it and send special response 
&lt;BR /&gt;Also, I try with a cTry and catch branch, but the route does not compile (see 2nd attached screenshot on my first post of the topic). Here is the code who does not compile 
&lt;BR /&gt; 
&lt;PRE&gt;								.to(uriMap.get("to Intermediate")).id(&lt;BR /&gt;										"cMessagingEndpoint_14").when().xpath(&lt;BR /&gt;										"/OrderStatus/Status='FINAL'")&lt;BR /&gt;								.to(uriMap.get("to Final")).id(&lt;BR /&gt;										"cMessagingEndpoint_11").doCatch(&lt;BR /&gt;										java.lang.Throwable.class).process(&lt;BR /&gt;										new org.apache.camel.Processor() {&lt;/PRE&gt; 
&lt;BR /&gt;The error displayed is 
&lt;BR /&gt; 
&lt;FONT color="red"&gt;The method doCatch(Class&amp;lt;Throwable&amp;gt;) is undefined for the type ChoiceDefinition&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Any ideas/suggestions? The version of Talend I'm using is 5.1.2.r90681 Professional Edition 
&lt;BR /&gt;Best regards, 
&lt;BR /&gt;Enrique</description>
      <pubDate>Thu, 21 Nov 2013 12:10:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233328#M23028</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T12:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233329#M23029</link>
      <description>Hi Enrique,
&lt;BR /&gt;In your 'catch' path, did you specify the exception to catch? You may want to try java.lang.Exception instead to see if that clears it up.
&lt;BR /&gt;Another thing it could be is that your try/catch could be interacting with your ChoiceDefinition. Sometimes it helps to use cDirect components after a cMessageRouter if you have to use some of these other conditional components further down the line. So the modification would look something like this:
&lt;BR /&gt;1) Drop a cDirect in and point your cMessageRouter 'when' to it.
&lt;BR /&gt;2) Drop another cDirect and connect it to the orphaned route segment. Configure the new cDirect with a sensible name.
&lt;BR /&gt;3) Configure the first cDirect to point to the second.
&lt;BR /&gt;Hope that helps
&lt;BR /&gt;Ben</description>
      <pubDate>Thu, 21 Nov 2013 14:45:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233329#M23029</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T14:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233330#M23030</link>
      <description>I just remembered you're using 5.1.2, which I don't think has cDirect.
&lt;BR /&gt;So in place of all the cDirect components, you would use the cMessagingEndpoint. The URI to link two point together would simply be "direct:MyDirectEndpointName" on both ends.
&lt;BR /&gt;
&lt;A href="http://camel.apache.org/direct.html" rel="nofollow noopener noreferrer"&gt;http://camel.apache.org/direct.html&lt;/A&gt;</description>
      <pubDate>Thu, 21 Nov 2013 14:48:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233330#M23030</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T14:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233331#M23031</link>
      <description>Hi Ben, 
&lt;BR /&gt;Thank you for your response. I got that cDirect was equivalent to cMessagingEndpoint with "direct:xxxx". 
&lt;BR /&gt;As you can see in the screenshot I put, the exception I defined is "java.lang.Throwable.class". I did another try/catch block in other part of the route, and it worked without problem. 
&lt;BR /&gt;I tried with your suggestion, and I have to say that it worked! Indeed it seems that the Route compiler does not take into account what is after my cDirect, and the try branch finishes with it. 
&lt;BR /&gt;Now I have the desired behavior 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;. Thank you for your help 
&lt;BR /&gt;Enrique</description>
      <pubDate>Thu, 21 Nov 2013 15:15:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233331#M23031</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T15:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Reference header element in cHTTP in a Route</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233332#M23032</link>
      <description>Hey&amp;nbsp;&lt;BR /&gt;I have a header as endpoint url value of a service.I need to call the header value as a url in chttp component.&lt;BR /&gt;Can any one tell me how to set the header value in the chttp component URL&amp;nbsp;</description>
      <pubDate>Mon, 25 Aug 2014 14:17:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Reference-header-element-in-cHTTP-in-a-Route/m-p/2233332#M23032</guid>
      <dc:creator>krishna_g</dc:creator>
      <dc:date>2014-08-25T14:17:44Z</dc:date>
    </item>
  </channel>
</rss>

