In one of my earlier tutorials, I taught you how to develop SOAP web service in TIBCO with HTTP as transport. Now, in this step by step tutorial, you will learn how to develop SOAP web service in TIBCO with JMS transport.
In case of JMS based SOAP web services, JMS queues are used which store messages sent over JMS transport. JMS queues are maintained on a JMS Server. For SOAP JMS Web services in TIBCO, its mandatory to have TIBCO setup at both client and server side. On the other hand, for HTTP based SOAP web services, there is no such requirement in client side.
In this tutorial, we will create a web service in TIBCO that will receive age as Input and it will return eligibility status as response. We are keeping the web service logic as simple as possible here as purpose is to explore all the steps involved in developing JMS based SOAP service and not process implementation details.
Step 1: Create JMS Connection
For a JMS based SOAP web service, the first thing that we need to do is to create a JMS connection to a JMS queue. Create a JMS connection in your project by going to Add Resources–>JMS–>JMS Connection.
Complete configuration of JMS connection will be like below:
Now in order to test our connection, we click on Test Connection button. As you can see in the screenshot below, JMS Connection is successful in my case:
Step 2: Create Schemas for JSM SOAP Web Service input and output
Our web service will receive only one input which will be age of a person. To create XSD for this, choose XML Schema from XML Palette. So our XML Schema will look like below:
For our service, response schema is also going to be simple as we will be sending just a Status message in response. Add a response schema as shown in the below screenshot:
Step 3: Create WSDL in TIBCO Designer for SOAP JMS Service
We are going to follow the “contract first” approach for creating web service in which we will create a WSDL first and then move towards service implementation.
Add a new WSDL Resource in your project and double click on it. Now we need to create WSDL Messages for Input and Output of our web service operation.
For the Request Message (to be used as Input), we choose Request XSD that was created in Step 2. Request WSDL Message will look like below:
For the response, we create another WSDL Message and name it like ResMessage. In this Message, we choose Response XSD which was also created by us in Step 3.
Our Response WSDL Message will look like below:
Now that we have created WSDL Messages, we need to create PortType. If you are aware of Object Oriented Programming, you can consider PortType as a Class which contains one or more operations.
Our PortType will be as follows:
As I earlier said, PortType is similar to a class, so we need to add operations inside it. Add a new Operation inside the PortType after double clicking on PortType.
I have given the name GetStatus to my Operation here. In the Message Table of Operation, we choose Messages for Input and Output. These messages have already been created by us.
Operation will now look like below:
With this we complete our WSDL creation step. Now we will proceed with creation of a service from WSDL in next step.
Step 4: Create Web Service from WSDL in TIBCO
In order to create web service from the WSDL, right click on the WSDL in the Project window and go to Tools or multi-User–>Generate Web Service–>From WSDL
As you can see in below screenshot, our created service will be using JMS transport:
As you can see in below screenshot, service has been created in the specified Location along with a process for the operation that we have in our service:
Change the name of the service to something meaningful (I changed the name to SOAPJMSWebService) and also move the BW Process to the Processes folder for better code organization in the project.
In the transport of the service, I have chosen JMS transport which was created in Step 1. This will use JMS queue for messaging purposes:
Now go to WSDL Source for the created web service and save the WSDL in a .wsdl file in your local file system as shown in the below screenshot:
This completes our web service creation part. Now we need to implement TIBCO BW process which is associated with our Web Service Operation GetStatus.
Step 5: Implement TIBCO BW Process for Web Service
Our process created by TIBCO Designer will be simple in this case. It will have only a Mapper activity where we will set the message to be sent as output.
In the Input Editor of Map Data activity, create a new String as shown below:
In the Input tab of Map Data activity, I have used an XPath formula that if age sent from the client is above 18, it will give the message “You are eligible”, otherwise message will be “You are not eligible”:
XPath for this is shown in screenshot below:
And in the End activity of this process, we simply map this message so that it’s sent as response when service is consumed:
Step 6: Test TIBCO JMS SOAP Web Service Using Designer Tester
Our last step in this TIBCO Web Services tutorial is to test the service that we have created. For this, we need to create a SOAP Client process in TIBCO Designer first.
Create a new process and use SOAP Request Reply activity in the process. This activity will be used to consume the web service. In the configuration of SOAPRequestReply activity, for the service, choose the WSDL that we saved in step 4. (I loaded that WSDL in another process and using it from there).
As you can see in below screenshot; Service, Port and Operations are selected from the WSDL:
In the Input tab of SOAPRequstReply activity, we have to give some input value for Age. In this example, I have given it a hard coded value 44 for test purpose:
Now load the service in designer tester. Once service is loaded, next task is to load and run the SOAP Client process that we created above. As you can see in the screenshot below, our process has run and consumed the service successfully and has received the response based on the input data:
This completes out tutorial on developing SOAP Web service in TIBCO using JMS transport. If you have any questions, I am here to answer and help you out.