Need to create a proxy HTTP service on Talend ESB

Highlighted
Four Stars

Need to create a proxy HTTP service on Talend ESB

I'm fairly new to Talend (ESB or otherwise), so feel free to let me know if there is a better way to accomplish what I'm trying to do.

 

The problem I have to solve is that there is a program that performs HTTP POSTs with an associated JSON body and needs to talk to a service that accepts HTTP POSTs with url query parameters.  So I have to read the request from the client, extract the fields I need from the original request's body, and use those fields to generate the url for the destination server. To accomplish this I have used the following design:

  1. a cRest component acting as a server
  2. a java Bean modeling the JSON body (the cRest component is configured with that bean as its bean class)
  3. a cProcessor that extracts the fields from the bean and stores them using exchange.setProperty()
  4. a router put in place to filter out some cases (I stop processing on certain values from the original call)
  5. a cHttp component that will make the POST to the destination URL after setting the parameters using the properties set on step 3.

Steps 1 through 4 work great.  But I'm stuck on step 5.  I've searched and I have no idea how to access the properties I set in the previous step. I tried using the form style on the client configuration, but it seems to me it treats whatever I put there as a fixed string.

 

Any idea on how go about doing this?  As I said earlier, if there is a better way to do this, I'm not married to this design at all.

 

Thanks in advance.

 

Santi


Accepted Solutions
Four Stars

Re: Need to create a proxy HTTP service on Talend ESB

I figured it out.  For future reference, what I did was create a messagingEndpoint component, using the ahc schema (probably any other http type of connector would do the trick).  The key is that it doesn't really matter what url you specify on the actual component's configuration dialog.  It all can be overridden by editing the headers.  So I used a processor node and ended up calling setHeader(). Like so:

 

 

	exchange.getIn().setHeader(Exchange.HTTP_URI, "http://localhost:8080/");
	exchange.getIn().setHeader(Exchange.HTTP_PATH, "my/base/path/goes/here");
	exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
	exchange.getIn().setHeader(Exchange.HTTP_QUERY, "PARAMETER1=" + value1 + "&PARAMETER2=" + value2);

 

Tags (1)

All Replies
Four Stars

Re: Need to create a proxy HTTP service on Talend ESB

I figured it out.  For future reference, what I did was create a messagingEndpoint component, using the ahc schema (probably any other http type of connector would do the trick).  The key is that it doesn't really matter what url you specify on the actual component's configuration dialog.  It all can be overridden by editing the headers.  So I used a processor node and ended up calling setHeader(). Like so:

 

 

	exchange.getIn().setHeader(Exchange.HTTP_URI, "http://localhost:8080/");
	exchange.getIn().setHeader(Exchange.HTTP_PATH, "my/base/path/goes/here");
	exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
	exchange.getIn().setHeader(Exchange.HTTP_QUERY, "PARAMETER1=" + value1 + "&PARAMETER2=" + value2);

 

Tags (1)

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read