Friday, September 5, 2008

First encounter with Web Services on Java

In case you do not know what a web-service is, do head on down to the wikipedia page in order to get an idea of what they are. If I had to sum it up in one line I'd probably say it is "executing functions over the Internet, instead of fetching pages". Of course, that might be an over-simplification, but it if it gets you to read about it in detail on wikipedia, it serves my purpose :)

Some of you might be wondering what's so great about "executing functions over the Internet", that's what remote procedure calls are for. CORBA, RMI or DCOM do pretty much the same thing. Of course, if you read the complete page, you wouldn't ask that. It has advantages: it uses XML, (and in my opinion, when something which is already a vital asset begins to use XML, you'll have plenty of people supporting it in no time), it allows for loose coupling (SOA), and more...

The reason I put in the "and more..." is that Web Services are an industry-standard and has a lot of jargon. I discovered that this jargon and the complex standards can make this area almost intractable. I'd once tried my hand at a project that used Web Services in Python. The support at that time was iffy too, and the entire project was lost in an irretrievable maze of words I still had no idea about at the time I decided to scrap the entire thing.

About three years later, and I had to use Web Services for another project. There's a saying in hindi that'd summarize my views on doing that "doodh ka jala chaach bhi phoonk phoonk ke peeta hai" :D . It just means that I'd really want to test the waters before I went ahead. This time, I discovered, I had tools at hand to help me through the maze. In particular, Glassfish and Netbeans. I learned about it in a presentation given by Mr. Arun Gupta, and you can get some screencasts that should be just as good here or on his blog. Well, what a relief it was to use these facilities, as I never had to deal with the bare-bones of SOAP or WS-Security or WS-Transaction or WS-Policy. These were the very same words that'd I'd fumbled around with and tried to create right from the specifications on the W3C site all that time ago. Can't stress if enough: What a relief!

How do they do it? Well, Sun has created an entire stack of web services. It is called Metro, and starts with JAX-WS (Java API for XML WebServices) and then builds in all the other stuff I mentioned on top of it. You can have a look at the entire feature-matrix. And yes, inter-operability means that the code works with .net, whether client-side or server-side. It's called Web Services Interoperability Technologies (WSIT). If you want to know more, check out the project's site here

Now for the tools. Glassfish includes the reference implementations for all of this stuff, and if thus reliable. Not to mention, it Metro comes bundled with Glassfish, so minimal download and installation hassles. Next comes Netbeans, which allows you to just drag-and-drop your web-services. Client-side, server-side, it's all taken care of. Of course, I had Glassfish with Netbeans, and minimal hassles.

All in all, I can go right to developing using these tools after reading around, and watching the screencasts, in the maximum of a day. Pretty nifty, I you ask me.

No comments: