Wednesday, July 6, 2016

Supporting WSO2 Data Services in AppCloud


Data services allows you to expose your relational databases, CSV files, Microsoft Excel sheets, Google spread sheets as SOAP and REST services. This helps you to expose your data through API Management solution such as API Cloud where your partners can consume your data in cloud. To read more about data services, refer to online documentation.

To start deploying dataservices in AppCloud, you need to have a car file which contains data service artifacts(dbs). In this post, I will explain how to
1. generate CRUD operations for a database table and get a data service.
2. import generated data service into to Developer studio and update with datasource configurations.
3. create a car file including above data service.
4. deploy it into AppCloud.

Lets get a database created in AppCloud so you can use it for the sample.
        Login to App Cloud using https://apps.cloud.wso2.com/appmgt/site/pages/index.jag
Create Database

provide database name, user and password
Find jdbc url etc
Connect to database and execute below queries
mysql -hmysql.storage.cloud.wso2.com -uemusr_vEqJD7xK -p
show databases;
use employeedb_manjulaorg;
create table employee(id VARCHAR(10) NOT NULL PRIMARY KEY, name VARCHAR(100), address VARCHAR(100));
insert into employee values('01','john','Boston');
insert into employee values('02','Micheal','Dallas');
insert into employee values('03','richard','Chicago');
SELECT * FROM employee;


1. Generate CRUD operations for a database table and get a data service.
Local setup details
Download wso2dss-3.5.0.zip file from wso2 web site and unzip.
Copy mysql-connector-java-5.* jar to wso2dss-3.5.0/repository/components/lib/
Start the server(wso2dss-3.5.0/bin/wso2server.sh start)
Login using admin/admin user.

Create a data source
In configure tab, create a new data source as below. You can get the database connection url, username from AppCloud UI as above.

Generate data service

In main tab, click on Add/Data Service/Generate button. Select data source you created in above step and provide the database name you created in AppCloud.
Next select table you need to expose with CRUD operations.
Provide a name to data service with namespace etc.
Data service will be deployed successfully.
Check the services deployed in services dashboard.
Try out your generated service with tryit tool.
Above are very simple steps to get CRUD operations exposed as a data service on a given table. You might need to change the queries, come up with better operation names, result elements etc. You can get this done easily by editing the data service through wizard or xml editor.
You can access the deployable file created in above steps in below location.
wso2dss-3.5.0/repository/deployment/server/dataservices/EmployeeService.dbs

2. Import generated data service into to Developer studio and update with data source configurations.
Open developer studio and create a data service project.
Next create a data service by importing the locally generated EmployeeService.dbs file.


Delete default(config) datasource and add a new one(right click on EmployeeService(data) -> Add Data Source -> RDBMS -> MySQL).
Make sure to keep the data source id as 'default'.


3. Create a car file including above data service.
Create composite application project.


Right click on composite project and export car file.



4. Deploy it into AppCloud.
Login to AppCloud start creating a application.
 Upload the created car file.
Application is created. Check the logs to see any errors in your data service.


If you get the service deployed correctly, check the car deployment logs as below.


To invoke the data service, click on the launch link. You will have to change the browser url to append /service/EmployeeService?wsdl as below.
https://manjulaorg-employeeservice-1-0-0.wso2apps.com/services/EmployeeService?wsdl 
Open the WSDL using soap ui tool and invoke the operations.
To summarize,
Most part of this post is about coming up with your data service and exporting it as a car file using developer studio.
If you have your own data service that is working locally, you can bring it to cloud easily as explained in this post using App Cloud.
To deploy multiple services in a single container, you can package multiple data services into car file and upload.



I will explain steps for securing this data service with username token ws security policy in next post.


Tuesday, June 28, 2016

Continuous integration and deployment with WSO2 App Cloud

If you have started deploying applications into WSO2 App Cloud, you will look for automating the deployment and configure it with your internal infrastructures such as GitHub, Jenkins etc.



Read tutorial to learn more about it.

WSO2 App Cloud for hosting your services and web applications

WSO2 App Cloud helps you to bring your web applications and services into Cloud easily.

Do you need to get a public URL to your service or your web app?
WSO2 App Cloud generate one for you with your organization name, application/service name and version.
eg. https://manjulaorg-esample-1-0-0.wso2apps.com/
If you have your own domain, you can use it too, learn how to.


4.png 
Do you have valuable data to be shared with your partners, co-workers in a secure manner? 
  • Create a micro service and expose your data or
  • Create a data service and expose your data.
  • Secure your micro service or data service using user name tokens.
  • Expose your service as an API in API Cloud.

Your partners need to consume your API and build a cool web app?
  • Subscribe to interested APIs in API Cloud.
  • Get consumer key, secret (OAuth tokens).
  • Write a jsp web application or php or jaggery and deploy in App Cloud.

Ok, there is a sample you can try out for above use cases... Buzzword sample.
  • As an API developer, you write a simple micro service to collect new buzzwords. You open a non secured endpoint to your friends to send/vote buzzwords.
  • But you hide the results, to get the ranks about your buzz words, consumers has to subscribe to your buzzword API.
  • As an Application developer, your friend consumes your buzzword API and come up with a web application and show the buzzwords as a tag cloud.  
http://manjulaorg-buzzwords-1-0-0.wso2apps.com/

Try out more tutorials on App Cloud.

Wednesday, September 3, 2014

Developer perspective of WSO2 App Factory

As a web application developer, what are the challenges we face in day today development activities?
  • How easy to setup your IDE?
  • How long you take to find your applications, source code?
  • How often you build your code? Introduces compile errors.
  • How easy to get your build server configured and get an account?
  • How long it takes you to get an account in issue tracking system?
  • How long it takes you to configure servers to deploy your application? Port conflicts, firewall restrictions, lack of resources such as Memory, disk space,etc.
  • How long it takes you to continue development in next day? Start servers and IDE, get latest source code, build, deploy.
  • How easy to know your team members, how they contribute etc?
  • How easy for you to move your application from Development servers into Testing,Production servers? App does not work in Testing server but it works in my machine?
  • How often do you test your application in a clustered setup?
  • How do you manage your milestone releases?
  • How do you work in multiple applications? How easy for you to switch among applications?
  • How easy for you to do a quick demo on current progress of your application?

Friday, March 4, 2011

Getting Started With Intellij Idea With Useful Shortcuts

Here comes the very useful shortcuts to develop code fast with Intellij Idea,there are plenty of shortcuts available with any development environment, If we do not use them, it is like using a text editor rather an IDE.
Easy coding goes as follows.

psvm + tab = completes the main method

psfs + tab = public static final String

sout + tab = System.out.println("");


lets have a variable as
String name = "Manjula";
soutv + tab = System.out.println("name = " + name);

Ctrl + n = search a class

Ctrl + d = duplicate a line where cursor is, or duplicate the selection

Ctrl + w = select a word, line, code block(repeat the key combination)

Ctrl + Shift + w = de-select selection

Ctrl + Shift +up/down = move up and down the selected code

Ctrl + Alt + l = align code

Ctrl + Alt + I = auto indent lines

Monday, October 11, 2010

My luckiest days at work

There will be mainly bits and bytes of tech talks, great moments...

A great place to learn and improve, first training, parties, luckiest moments, really nice people to work with, all these will be here soon.