Entrance Power Guide to Talend ESB – Part 2
Time to enable XML mapping and join our data with string manipulation.
Enterprises generally work with hundreds of applications, and many of them must be integrated with one another. Enterprise application integration can often be a challenge for many companies; connecting applications through point-to-point integration is time consuming and costly, so many organizations turn to an Enterprise Service Bus (ESB) to make integration faster and easier.
In Part 1 of the Entrance Power Guide to Talend ESB for application integration, we imported the Web Services Description Language (WSDL) contract into Talend Open Studio for ESB and created all the elements of the service needed to build a CRM integration. Now we have the CRM data, the style of the service, and the end of the service defined and in place, and we are ready to configure error handling and load balancing to our CRM integration.
In this second installment of the Talend ESB Power Guide Series, we will show you how to:
- Set up Talend ESB to enable XML mapping of the CRM source data through our inputs and outputs.
- Join our CRM data sets via in string manipulation in Talend Open Studio.
- Create a SOAP-based error response
In Part 3, we will implement a load balancing integration pattern to provide more visibility to the endpoint so, finally, we can test a fully load-balanced, SOAP-based Web service provider to ensure our CRM integration is functioning properly.
Mapping Within Talend Studio
The most powerful and widely used features within Talend Open Studio are the mapping components. In this ESB demo, we are using a TXMLmap to enable XML mapping to be performed. (There is a corresponding map component available for non-XML resources as well).
In the screen below, we label the inputs into our mapping steps. We do this by drawing lines between the steps and naming them, one to indicate it is a request coming in from the service base, another indicates the information is coming in from the customer resource, and another map the output to the service response. Finally, we create an output to our fault component, because we also want to generate SOAP faults in this CRM integration.
To view the actual output in the containers, we go to the right-hand navigation to log the output. On the screen below we can look at the source bit of information, and see the incoming request of the service, the customer schema that is being extracted from the customer resource, and the response to the service (this includes normal and fault responses).
In the middle of the screen are all the different operations of the service we imported. We are interested in the “getCustomer” operation, which we select from the menu. This indicates we will martial that data for the request according to the “getCustomer” request schema contained in the WSDL.
The new request is added to the main request box in the upper left-hand corner. We then follow the same steps to add the “getCustomer” operation to the error handling and fault response sections.
On the left-hand side of the screen, we see all the inputs, and on the right side are all the outputs to the XML map. The next step is to set up the ESB to enable us to map and transport data through the inputs and outputs.
First, we create a lookup between the two boxes on the left side: the service requests (top) and the customer data resource (bottom). To do this, we simply drag and drop the element (in this case “custId”) down to indicate we want it to join the customer resource (lookup: customers).
Essentially what we are saying is that we want to join the incoming customer ID that comes with the service request to the customer ID that lives in the customer resource.
When the Data Doesn’t Jive: Setting up a Join and String Manipulation
Now we need to set a mechanism to integrate the CRM data every time the service executes. The “Match Model” is set to be a “Unique match” and the “Join Model” is “Inner Join”. With those parameters set, we can start mapping the data to the endpoint.
Mapping the data in this join is a simple case of drawing a drop. (See the lines in the screenshot below.)
One slight complication we see is that the name of the service response on the right, “name”, is a catenation of the entire name, and the customer resource on the left represents “name” with a string of multiple components (salutation, forename, etc.).
To address this, we build a small transformer by clicking “Var” in the middle column and enter “name” under the “Variable” column. Next, we highlight the “Salutation,” “Forename,” and “Surname” rows and drag them to the variable box in the “Expression” column.
We then click on the box in that column and in the new window, there are three ways we can catenate the string of “Salutation”, “Surname”, and “Forename” together:
- Use out of the box functions.
- Write our own custom routines.
- Write simple JAVA syntax.
After the name is resolved, we map all the components across the screen (see below), again a drag and draw. This sets the connections so we get the standard response to the service.
Creating the SOAP-Based Error Response
Next, we set things up to generate standard SOAP faults for the service. The process is similar to how we just mapped the CRM data.
First, we select it to catch what we call “inner join rejects,” meaning if the customer can’t be found we get an error response from the service. To configure the error response, we type “err001” to be the base label for my error, and by “Type” enter “Lookup failure” to indicate what the error is.
Finally, by “Message” we enter a meaningful message to the service in the event it can’t find the customer (“Unable to locate customer”). Finally, we take the drag the original input, “custId,” and drag it over to the “fault” section.
Now our service is fully ready, and in the Entrance Power Guide to Talend ESB – Part 3 we will demonstrate how to implement a load balancing algorithm, and check out some of the mediation and routing capabilities available within Talend Open Studio for ESB.
We invite you to try this for free with Talend Open Studio for ESB and see how easy it is to implement a simple CRM integration like we are demonstrating, or set up your own Web services integration.