Combining Services in Bluemix
Bluemix has a set of services that can be combined in a single web application (e.g., output of one service will serve as input of another service).
In this tutorial you will learn how to combine services in IBM Bluemix.
Prerequisite:
You are required to do the Creating a Web Application using Gradle Tutorial.
- The steps used in this tutorial is based from Creating a Web Application using Gradle Tutorial.
You are not required (but recommended) to do the Bluemix Basics Tutorial.
- However, ensure that you have a Bluemix account.
- Your account should have the space
devunder the regionUS-South. The creation of the spacedevis discussed in Bluemix Basics Tutorial.- Make sure that the
cftool is installed. The installation ofcftool is discussed in Bluemix Basics Tutorial.You are not required (but recommended) to do the GitHub Basics Tutorial.
- However, ensure that you have a GitHub account.
Copy Sample Codes from Git repository
Open a terminal window and create the directory
gradletempin the root directory. Go to the created directory.> mkdir bluemixtemp > cd bluemixtempClone the git repository
https://github.com/pong-pantola/bluemix-combined-services.gitand go to the createdbluemix-combined-servicesdirectory.> git clone https://github.com/pong-pantola/bluemix-combined-services.git > cd bluemix-combined-servicesAssemble the Gradle project.
Make sure that you are in the
bluemix-combined-servicesdirectory before issuing the command below.> gradle assembleOutput:
:compileJava :processResources :classes :war :assemble BUILD SUCCESSFUL Total time: 9.289 secs
Deploy the Web Application in Bluemix
Login to your Bluemix account using the
cftool.Make sure that you are in the
bluemix-combined-servicesdirectory before issuing the command below.> cf login -a https://api.ng.bluemix.net -s devUpload the web application to your Bluemix account.
> cf push combination-<your_name> -m 512M -p build/libs/webapp.warExample:
> cf push combination-pong -m 512M -p build/libs/webapp.war
Add Bluemix Services to the Web Application
Open a web browser and login to your Bluemix account.
Click the widget of your application (
combination-<your_name>) to see its overview.Click the
ADD A SERVICE OR APIlink. You will be redirected to theCatalogpage.Look for the
AlchemyAPIservice and click it.In the
Service nametext box, use the default name.Click the
CREATEbutton.When asked to restage your application, click the
CANCELbutton.If you click the
RESTAGEbutton, your application will restart. It is advisable to click theRESTAGEbutton once you have added all the services, otherwise your web application will keep on restarting every time you clickRESTAGEwhich will make the procedure of adding services longer.Repeat the steps above to add the following services:
- Language Translation
- Speech To Text
- Text To Speech
- Cloudant NoSQL DB
- Object Storage
- mongodb (not MongoDB by Compose)
- redis (not Redis by Compose)
VERY IMPORTANT:
For monogdb and redis, as mentioned above, do not use the version "by Compose". Instead, in the
Catalogpage, scroll down in theCATALOGpage until you see theBluemix Labs Cataloglink. Click this link. Look for the services namedmongodbandredis.When you add the last service (redis), you will be asked to restage your application, click the
RESTAGEbutton. If you don't click theRESTAGEbutton, your application will not restart and it will not recognize all the services you added.Wait for your application to restart.
On another browser tab, go to
http://combination-<your_name>.mybluemix.net.Output:
Alchemy-Cloudant Alchemy-MongoDB Alchemy-Redis Alchemy-TextToSpeech LanguageTranslation-TextToSpeech ObjectStorage-SpeechToText TextToSpeech-ObjectStorageYou have successfully deployed the web application in Bluemix.
Test the Application
Each hyperlink demonstrates how two services are combined. For example, the link Alchemy-Cloudant demonstrates how the output of Alchemy API is used in Cloudant NoSQL DB.
Alchemy-Cloudant
This asks a user to enter a URL of an image file. The image should contain at least one person. Alchemy API will extract information from the image. Specifically, it will extract the age and gender of the person in the image.
The extracted age and gender are saved in a Cloudant NoSQL DB service.
Alchemy-MongoDB
This is the same as Alchemy-Cloudant except that the extracted age and gender are saved in a mongodb service .
Alchemy-Redis
This is the same as Alchemy-Cloudant and Alchemy-MongoDB except that the extracted age and gender are saved in a redis service .
Alchemy-TextToSpeech
This is the same as Alchemy-Cloudant, Alchemy-MongoDB, and Alchemy-Redis. However, instead of saving the age and gender, it will create a WAV file that contains the following sound:
Information Extraction Complete. The person in the picture is a <GENDER>. <His/Her> age is <AGE>.LanguageTranslation-TextToSpeech
This asks a user to enter a text in Spanish. Using the Language Translation service, it will convert the text to English. The English text is converted to a speech (i.e., WAV file) using the Text To Speech Service.
ObjectStorage-SpeechToText
This asks a user to select a WAV file containing an English sentence. The WAV file is uploaded in an Object Storage service.
From the Object Storage service, it will download the WAV file and convert it to its equivalent to text using the Speech To Text service.
TextToSpeech-ObjectStorage
This asks a user to enter a text. The text is converted to speech (i.e., WAV file) using the Text To Speech service. The WAV file is uploaded in an Object Storage service.
Clean up
Delete your Bluemix application
combination-<your_name>.Make sure to delete as well all the created services.
End of Tutorial
Go back to the List of Tutorials.
