Monday, April 28, 2008

Say Hello to WSO2 Mashup Server

You have heard about it! You have read about it! You may even have dreamt about it! The WSO2 Mashup Server is a platform for creating, deploying, and consuming Web services Mashups in the simplest fashion possible. And when I say simple I mean like a piece of cake. In fact you don't have to know a damn thing about Web services to get started with the WSO2 Mashup Server. Some basic knowledge on JavaScript is all you need. Now how cool is that?

So today I'm going to provide some guidelines to those out there who are willing to get their hands dirty with this whole Web services Mashups thing. After reading this entry you will realize how easy (and not to mention the fun) it is to develop and deploy Web Services Mashups with the WSO2 Mashup Server. Provided that you have Java 5 or a higher version installed on your computer the first step is to download the Mashup server. Extract the downloaded archive and go to the bin directory. Simply execute the server startup script relevant to your operating system. Windows users should execute the startup.bat and Linux users should execute the (you might need to set the execution permissions for this file). The server will start throwing out a bunch of text on your console and when the server has successfully started you will see something similar to the following.

INFO [2008-02-15 10:57:14,690]  HTTP port            : 7762
INFO [2008-02-15 10:57:14,691] HTTPS port : 7443
INFO [2008-02-15 10:57:14,691]
INFO [2008-02-15 10:57:14,691] WSO2 Mashup Server started in 51597 ms

Now open up a Web browser instance and browse to the URL http://localhost:7762. You will be provided with a form to create a user account for yourself since this is the first time you are signing in to the Mashup server. Simply fill in the form and submit to create your account leaving the sign in check box checked. At this point you should be seeing your Mashup server home page.

And now begins the fun part. Click on the 'Create a new service' link under the management tasks. Give a name to the service and click create button. For this simple demonstration I'm going to create a service named 'helloworld'.

Then you will be provided with an editor to write your mashup. You may notice that a considerable amount of coding is already done for you but that is really not necessary at this point. Remove all that code and copy and paste the following code segment into the editor.

this.serviceName = “helloworld”;
this.documentation = “My first mashup”;

sayHello.documentation = “Greet”;
sayHello.inputTypes = { “name” : “String” };
sayHello.outputType = { “String” };
function sayHello(name)
return “Hi, and welcome “+name;

What we have done here is defining a simple service with one operation. The name of the operation is 'sayHello'. It takes in a string parameter called 'name' and returns a string value. More specifically when you invoke the operation sayHello with a name like 'Joe' it will return the string 'Hi, and welcome Joe'. Now click on the 'Save changes' button to save your workings. It will take some time to your service to get properly deployed and listed under the' My Mashups' list on the home page. If it seems to be taking too much time simply refresh the page.

Click on 'helloworld' link under 'My Mashups' to see the details of the helloworld mashup. Now you can go about and start playing with your mashup.
Do not forget to test your mashup with the 'Try It' feature.

Also you can view and edit the source of your mashup, give a rating to it, view the WSDL for the service and do a lot more. See how easy it is to get up and running with the WSO2 Mashup Server? Did you have to use any serious Web services stuff? No! Did you have to do any complex Java programming? No! All we did was typing a few lines of simple JavaScript code and making a few clicks here and there on a nice looking web interface. Now if you have signed up on you can directly upload your mashup to the mooshup community site by using the 'Share Mashup' feature so other mashup developers can have a look at your mashup. Sounds fun! Isn't it?

No comments: