HTML Rendering in Mule-Part 4
- September 14, 2020
In this article, we will try to understand the working of Parse Template for multiple records, where we will try to send the bulk of the record in a single response. Let us assume that the admin department wants the details of all the employees at any given time. How will we cater to this request?
Keeping the rest of the configurations the same, we will just change the configuration for Parse Template and add a new Transform message component. Send Email and Read File operation inherit their configuration properties.
All the new configurations are done so as to achieve this as shown below (the rest of the values are set to default or as done previously):
- Transform Message:
- Parse Template:
Also, since this functionality will be used by the Admin team occasionally, hence I have planned to replace the scheduler with HTTP Listener listening to the “test” endpoint.
Once the application is ready to be deployed, let’s run the application and test it.
- While making a call to http://localhost:8081/test using a browser, the response received will be “Mail sent successfully” due to set Payload.
- If you check the mail, you will be able to see the employee details as shown below:
Now, you have a basic understanding of sending a well-formatted HTML response using dataweave. We can even extend the same to other data sources like a Relational Database or NoSQL with some slight configuration changes.
Now let us think about how we can extract the data from HTML responses.
For demonstration purposes, I have taken my first blog published on wordpress as an example. Look into the code mentioned below to get an idea of how to retrieve the details from the HTML response using dataweave (Note: there are other examples to do the same; using java libraries too).
I hope you got to learn something new from this walk-through. Do post your responses in the comment to let me know that your application is running. Till then continue reading the other blogs that I have written and let me know your thoughts on those.
— By Abhinav Patel