In a previous tutorial, I taught you how to receive data in TIBCO BW process using HTTP POST method. In this tutorial, I will teach you how you can receive data in TIBCO with HTTP GET Method.
So you are well aware of the difference between HTTP POST and HTTP GET in general? If yes then that’s great. If not, I am here to tell you!!
In case of HTTP POST, data sent from sender is received in the body of HTTP message which can be then accessed in TIBCO process from PostData variable of HTTP Receiver. This data doesn’t become part of HTTP URL while sending request towards HTTP Server.
On the other hand, in case of HTTP GET, data (parameters) sent from the client are sent as part of HTTP URL and these parameters are then accessed in TIBCO Processes from Parameters variable of HTTP Receiver.
Ok, now we move forward with step by step tutorial on working with HTTP GET data in TIBCO. We are going to develop a HTTP based process which will take a file name as input through GET method and then it will return contents of that file as HTTP Response. In case it fails to find the file, it will return a custom HTTP Response message.
Step 1: Create HTTP Connection
Anytime you go for HTTP based messaging in TIBCO, first step is to create HTTP Connection. From the HTTP Palette choose HTTP Connection activity and drag it in your project design window.
Now configure your HTTP Connection by specifying IP, Port etc. as shown below:
Step 2: Create TIBCO Process to receive HTTP GET data
In order to receive HTTP GET data in TIBCO, we create a new process and use HTTP Receiver activity as process starter for it.
In the configuration tab of HTTP Receiver, choose HTTP Connection (that was created in step 1). In the parameters option, click on (+) sign to add a new parameter. This parameter will be used to receive HTTP GET data.
Complete configuration of HTTP Receiver activity will look like below:
As you can see in below screenshot, newly created parameter is now available under parameters in the Output tab of HTTP Receiver:
In order to read file contents, we use Read File activity in our process. In the Input of Read File activity, we have used the file name that we received as HTTP GET parameter. We have concatenated this file name with our path to give absolute file path as shown in below screenshot:
We will have two transitions from our Read File activity to the next activities. In case of Success of Read File activity, we will have a transition to Send HTTP Response activity to send file contents.
In the configuration tab of Send HTTP Response activity, we choose HTTP Receiver for which we are sending back this response as shown below:
In the Input tab of Send HTTP Response activity for success cases, File Contents read through Read File activity are mapped which will be sent as response data.
Input tab mapping of Send HTTP Success Response is shown in below screenshot:
In case of any error in Read File activity, error transition will be followed and Send Failure Response will be used to send response back to the client.
In the Input tab of this failure HTTP Response activity, we are sending a custom message as shown below:
Now we are done with our process development. Validate the project and after successful validation, move to the testing step.
Step 3: Test HTTP Get Method in TIBCO
Before testing the process, create some files at the path which was specified in Read File activity. In my case, I have created two files (student.txt and teacher.txt) at the given path as you can see below:
Load the process in TIBCO Designer tester. After loading the process in tester, go to your browser and type following in the URL field:
As a file with the name teacher.txt was present at the given path, so I got following response back on my browser window:
You can also observe from above screenshot that success transition path has been followed in our process as file was successfully read by the process.
Now in order to test failure scenario, we will give a filename in the URL for which file doesn’t exist. For this, I typed following URL in my browser:
Now, we got error message in response and we can also see from the below screenshot that now, error transition has been followed (as file read activity failed):