Well I'm Varun Bhatia and I'm currently pursuing Master of Computer Applications from Department of Computer Science, University of Delhi and my hobbies include listening to music & watching movies.
Well I'm here to discuss about a project, which i undertook a few months back, that needed to involve web services. As you may or may not know, web services is the name given to a technology that seeks to solve a prominent and long existing problem, the exchange of data between programs written on different platforms. The problem, of course, has associated history. Ever since a couple of people wrote programs that did logically associated things, they've wanted them to communicate. Via a network, or just read each other's data from a disk. Well, lots of technologies made this easier than it was in those days, of course :) Using the same programming language, the same operating system, and later, the same platforms (java, .net) made this possible in some way or the other. In order to make this communication easier still, technologies came up such as DCOM and CORBA.
Think of the technology that made communication between people around the world possible. Yup, the internet. Now, think of the technology that made storing data possible, using the techniques used in HTML, the language of the Internet. That was XML. Now, try to apply the same to communicate in terms of functionality, rather than data. That is web services. Nothing more, nothing less. It is a set of standards that make proving functionality over the Internet possible.
Of course, I needed an application, and not just a bunch of standards. For this, I wanted to go with one of the more mature implementations. Java, and .net fit the bill. I already knew Java, so that became the obvious choice for me. Fortunately for me, I also had help at hand. Sun Microsystems has a representative at our campus, under a program called the Sun Campus Ambassador program. I asked him to guide me in this task, and he duly obliged. I decided to go with the choices that he proposed, though not without good reason.
Glassfish Application Server
The web server, of course was the first choice to make. Except that I did not just need a conventional web server, I needed something that would support web services. That generally means something the industry calls an application server. Well, Apache is the most popular web server around, and it makes sense to use a derivative. Apache Tomcat is the project that adds servlet support to the same. Then of course, it should support web services. This was where Glassfish became an obvious choice. It's free, open-source, and its web services stack seemed good. Other good things include its features, directory layout and management controls. It's got awesome potential. I found GlassFish very simple to use and would recommend it for new users to develop and deploy their J2EE applications via its simple web page layout and work flow. However, I definitely found the GlassFish application server slow over Tomcat. Well, extra functionality doesn’t come free. And of course,that might improve with the next version, Glassfish v3.
MySQL Database Server
The database server had to be light. I wasn't making a large application. Hence, using a corporate server did not make sense. Of course, I needed the entire set of features nonetheless. :D Fortunately, the open-source database server market is very mature, so I had no problem at all. The choice to make was primarily between 2 offerings, PostGRE and MySQL, I chose MySQL. It is conceptually very simple and that enables a tremendous amount of flexibility, a must for a new user. Being open-source, MySQL’s files are extremely portable between versions & between operating systems. That means an upgrade at any point of time is dead simple, as you don't need to dump/restore your data. Further all MySQL table types (except InnoDB) are implemented as files (one table per file), which makes it really easy to back up, move, delete, and even symlink databases and tables. And, that’s a big advantage.
Fig 2 : Query Browser of MySQL
I needed an IDE to speed up my work, and NetBeans provided the ideal answer, since it provides support for Glassfish and MySQL. And of course, it supported the creation of web services, which I thought, would come in very handy. Of course, the fact that I just had to drag-and-drop a web service, and not add the annotations by hand took away a lot of problems I suspect I would have had. Other small, but very important benefits include that NetBeans was easy to install and to use. I found NetBeans very easy for performing some very basic tasks like code completion, refactoring, running and debugging.
I wanted to pick up a project that would have allowed me to showcase the maturity of the web services platform. For this reason, I thought up a web service for a stock exchange. It would allow users to log-in, view the companies listed, and buy and sell shares of the listed companies. It sounded good enough, and I got to work.
I decided on the database first, of course. I used the MySQL query browser tool in order to execute my queries. Command-line functionality is good, but Ipreferred a GUI. Incidentally, I could've used Netbeans for this purpose, but I just wasn't aware that that functionality was available as well. For the web-services part, I decided to make three of them, and break the functionality according to the types of users that I expected. The functionality for each of the web services would be given by classes that would work behind the scenes. Thus, the same functionalitycan be used for other purposes too. As a matter of fact, web-services are made by the web-server using annotations.
Honestly, the coding part was not that different from how I'd code in traditional Java. As a matter of fact, it was the same. I needed a JDBC driver for running MySQL queries from my Java, program, and I got the same here. One other function that I really liked was the ability to test web-services. It really made my work a little less tedious and very easy for me to view the various processes that were executed in the background.
I did run into a couple of problems though. The most perplexing one was that my application needed to store-session based data i.e. since a user could've logged in, and only then accessed functions, this fact must be stored, since the functions will be used in another access altogether. Not the best explanation, I know, but people who've done some web designing, know what I'm talking about. Trouble is, I could not easily find a way to do so. Had to take some help and it taught me a good lesson in searching on Google. While I was searching for sessions in the Metro web-services stack, the one used by Glassfish; my friend tried searching for sessions in JAX-WS, the underlying part of Metro that handles SOAP. Well, I found
this blog, and it served my needs. I also ran into some trouble when a Netbeans download did not have JAXB, and the same blog helped me out < href="http://weblogs.java.net/blog/ramapulavarthi/archive/2007/01/problems_using.html">again. Hence, I thought I should also start blogging some-time.
That was it for quite some time I finished the project to my satisfaction, happy at the fact that I'd understood well enough what web-services are. Some time later, a mail on our Java User Group came in that listed a competition that required an application that demonstrated the capabilities of Glassfish and MySQL. I thought, this should be a good fit. Imagine my surprise when I found out that their website listed a similar project to the one I had made. Though, that was a Microsoft project. Yup, interoperability means Microsoft and Sun ensure through the WSIT project was just the start. Unfortunately, I did not understand as much of the guide as I would have liked, thanks to ignorance about .net. Nonetheless, I've done what every self-respecting open-source fan would do... post the project on an open-source website, and try to get other people to help out on the same.
At last, I would like to thank Aadhar Mittal(our SUN Campus Ambassador) and Himanshu Bansal, two of my classmates, for their valuable support and suggestions throughout the project that lead to successful completion of this project.