Table of Contents
- Objective
- Before you Start
- Starting TIBCO Business Studio? Cloud Edition
- Implementing our API Specification
Once you modeled and tested your API, the implementation can start. To get from modeling to implementation and testing your business logic is as easy as dragging and dropping activities.
Objective
In this tutorial we will be using TIBCO Business Studio? - Cloud Edition to implement and deploy an API to TIBCO® Cloud Integration without writing code.
Before you Start
Login to your TIBCO Cloud Integration account, by going to http://cloud.tibco.com/ and clicking in the Sign-in link at the top of the screen.
If you do not have an account yet you can start a free 30 day trial from the http://cloud.tibco.com/ page.
This tutorial is will be using the API we have modeled in Creating my First API on TIBCO Cloud Integration so it assumes that you have already completed that tutorial.
Starting TIBCO Business Studio? Cloud Edition
In this tutorial we are going to use TIBCO Business Studio? - Cloud Edition which is included in your TIBCO Cloud Integration subscription.
Once logged in download TIBCO Business Studio? Cloud Edition for your operating system and install it in your workstation.
TIBCO Business Studio Cloud Edition is an Eclipse based platform that will enable you to design and create your API workflows and is fully integrated with TIBCO Cloud Integration. Allowing you to publish and work with the all the applications you have deployed in the cloud.
- The first thing we need to do once we have TIBCO Business Studio running in our workstation is to connect it to out TIBCO Cloud Integration account. To do that we will focus on the API Explorer view.
- To do this in the API Explorer View go to the down arrow icon on the far right side of the windows and select ?Settings?
- In this Settings window you will see the TIBCO Cloud Integration Connection already set up for you. We just need to add our login credentials.
To do this we select the Cloud Configuration in API Registry Configurations and click
- Under Authentication fill in with the same the username and password you use to login to your TIBCO Cloud Integration (http://cloud.tibco.com) account and click Finish.
- Now the API Explorer will refresh and you should see the list of API Specifications you have modeled on your TIBCO Cloud Integration account. AT this point you should see the Hello World Spec we modeled in the previous Tutorial.
With this taken care of we can move on to build a new application to implement our Hello World API we defined in the previous tutorial.
Implementing our API Specification
To implement the API we have defined we need to create a new Application in Business Studio. Just right-click on the Project Explorer window and select New -> BusinessWorks ApplicationTo create the new application we just need a Name, remember that application names can only contain lowercase letters (a-z), numbers (0-9), dots (.) and underscores (_)
In our case we will choose ?hello_world_app?, just put the name in the new Project dialog and leave all the other options with their default setting, and click FINISH
TIBCO Business Studio Cloud Edition will create all the assets needed to start implementing our API in our application.
To start implementing our API we now need to Drag and Drop the API Specification, we already created in our account to our new project
Now click and Drag the Hello World (1.0) API from the API Explorer Window to the Service Descriptors folder in our project.
This will import your Specification in your projects and create all the assets needed to start implementing.
As you remember from our previous tutorial our HelloWorld API has a GET method called ?greeting? that will receive a ?name? as a parameter. And you can see all that in your project now. To implement the response of this method we just need to Drag the resource ?/greeting? into the canvas on the right.
(Hint: Make sure you drop it outside the Process flow, as marked in the Screenshot)
Now you can see the implementation of our GET request. In this example implementation we want our API to respond to the /greeting GET request with a string that contains ?Hello ? concatenated to the {name} passed as a parameter.
This way when we call the method with a parameter i.e. GET ./greeting/World our API will respond with the String ?Hello World?
To modify our return response to the get method we simply add a default statement to the activity called getOut.
Let?s do it!
- Select the getOut Activity by clicking on it
- Now go to the Properties window below and click the Input Tab
- Once in the Input Tab Click on XPath Expression next to the returned Item to add our response
This expression will be the response to our GET request, remember we want the response to ve the concatenation of the word ?Hello ? and the parameter that was passed in the request.
- Let?s build our expression!
No need to write any code here, just click on Functions and search for ?concat? under String Functions and drag the function to the expression box.
The concat function is pretty simple just accepts two strings, based on our response the first string should be ?Hello ?. Now go ahead and replace << string1 >> with ?Hello ?
(Hint: don?t forget the quotes in your string ) Now for the second part we need to use the GET request parameter. We can find it in the Data Source Tab by expanding the tree on $get -> parameters -> greetingGetParameters -> name
Just drag and drop the parameter name over << string2,... >>
Your expression is now done! It should look like this:
- And we are done!! So go ahead and save your Process by going to the menu and selecting FIle -> Save
Very Simple. Just go to the Project Explorer and right click on your Application in our case ?hello_world_app? and select Push to Cloud?
(Note: Business Studio creates 2 objects in the Project Explorer for you one is the BusinessWorks Application Module that uses this icon and ends.
And the other object is the actual BusinessWorks Application itself which uses this icon )
That?s it! No call to IT no meeting with Cloud Ops, nothing. All is taken care by TIBCO Cloud Integration for you.
Now again is time to test our Application.
Go to your TIBCO Cloud Integration account and in the Apps page you will see the Application we just have deployed (hello_world_app) from Business Studio ready to go.
Remember the Green Circle next to the App name means that the app is deployed and ready.
Similar to what we did with our Mock-Up application, by clicking on and then on will launch the TCI API tester. Now to test our Response, let?s enter some value in the parameter, like ?Cloud?Then click on ?Try it Now!? and you will be able to see your API implementation working!! Returning ?Hello Cloud? in the Response Body
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now