HTTP based connectivity between different applications and between different processes inside a TIBCO BW project is a common thing that TIBCO developers come across. When it comes to transfer of data through HTTP, you have two options available:
- Send data through GET method in which parameters sent in HTTP request get concatenated to the Request URL.
- Send data through POST method in which data is posted as part of HTTP request body.
In this tutorial, I will explain step by step, how you can send HTTP Post data and then receive and parse the same data using HTTP Receiver activity.
Step 1: Create HTTP Connection:
In order to develop any HTTP Based solution in TIBCO, the first task that comes in my mind is creation of a HTTP connection. Add a new HTTP Connection from the HTTP Palette and configure HTTP connection as shown below:
The configuration shows that this connection will be used to enable HTTP communication on localhost at port number 8899.
Step 2: Create XML File and Associated XSD Schema:
In our tutorial, we will send an XML file through HTTP Post. So let’s first create XML file. I am going to use a simple XML File with an employee basic information as shown below:
Whenever you play with XML files in your TIBCO BW projects, you have to go for XML schemas. So let’s create XML Schema (XSD File) for this XML.
Our XML Schema created for this type of XML files is as shown below:
Step 3: Create TIBCO Process to Send HTTP Post Data:
We will create a TIBCO BW Process SendHTTPPostData that will read XML data stored in a local file and then it will use Send HTTP Request activity to send the data towards a process where HTTP Receiver will be listening on given IP/Port to receive the data.
To read XML File, Read File activity is used. As shown in below screenshot, I have given path of XML file which will be read by this activity:
Below is configuration of Send HTTP Request activity. As you can see, same Host and Port are specified here which were used while creating HTTP Connection in Step 1. As we will be sending data through POST method (and not GET method), so I haven’t added any parameters here:
In the Input tab of Send HTTP Request activity, I have specified “POST” as method and in the PostData, XML file content read through Read File activity have been specified:
That’s it for our sending side. Now we need to move towards development of other process which will receive POST data and do any processing logic required.
Step 4: Create TIBCO BW Process to receive HTTP Post data:
HTTP Receiver activity is used as process starter in our receiver process ParseHTTPPostData. As you can see in below screenshot, HTTP connection created in step 1 is specified in configuration of our HTTP receiver activity which means it will be listening on the IP and Port given in our HTTP Connection. In Output Style we have chosen String as we will be sending text based data.
Complete configuration of HTTP Receiver activity will look like below:
In our process, after receiving HTTP Post data in the form of an XML string, we will use Parse XML activity. In Parse XML input tab, HTTP Receiver’s PostData is mapped to XMLString as shown in below screenshot:
In the Output Editor tab of Parse XML activity, choose Employee XSD that we created in step 2 as shown below:
Now output tab of Parse XML activity will look like below based on the Schema that we selected above in Output Editor tab:
After parsing XML data received through HTTP Receiver by POST method, now we won’t be doing any other activities in the data in this tutorial. We just need to send HTTP Response to the sender to tell that everything has gone fine at receiving side.
For this purpose we will use Send HTTP Response activity. In the configuration tab of Send HTTP Response activity, choose HTTP Receiver in Reply For drop down. Configuration of Send HTTP Response will look like below:
In the Input tab of our Send HTTP Response activity, we are going to send a simple String in response with the text “Request Received Successfully.” as shown below:
That concludes development of our both processes and now we are good to go for testing our HTTP Post based solution.
Step 5: Test TIBCO HTTP Post Data
Validate the project to make sure everything has been developed and configured properly. After successful validation, load both processes (SendHTTPPostData process and ParseHTTPPostData process) in designer tester.
Create a new Job for SendHTTPPostData process and you will see that both processes have run successfully.
To verify that everything has worked fine, go to the process SendHTTPPostData in tester mode and look into the Input Data tab for Send HTTP Request activity. As you can see in below screenshot, correct PostData has been sent by our Send HTTP Request activity (XML file contents read by Read File activity):
Now if you see Output tab of Parse Data activity in process ParseHTTPPostData in tester mode, you will see that It has rightly parsed Post Data that was received by HTTP Receiver as shown below:
If you go to Input Data tab of Send HTTP Response activity, you can see that It has successfully sent the response to the sending activity:
Now you can go to output tab of Send HTTP Request activity and verify that final response has been received: