A couple of days back I received a query from one of my colleague on how one can actually access the Bluemix services from the application code. While I have some information covered this in one of my post earlier here
I thought of having a dedicated entry regarding the same as this is an important information from application development prospective.
So whenever you create an application in Bluemix, and bind a service to it, you need some access parameters (or any other information which allow you to consume the service in an application). Taking an example of a database service bound to my application, I will be needing URL, Hostname, userID and password information so that I can create a JDBC connection from my application. Bluemix create a environment variable VCAP_SERVICE in your application runtime to store such information. So if you are writing a Web Application, it will be under your Web Server (Liberty) runtime. To get this information, you can click on the runtime under your application and you will see this variable under environment variable. Below is the snapshot for this
You can also parse this information dynamically from you application (instead of hard coding these values). Here is the example code for the same
Now you can develop your application using Eclipse and use these credentials to connect to the service (database in this case) and work with it.