Thursday, March 27, 2008

A closer look at Web Services

People loves abstraction. Kids start to learn numbers by first counting actual items like apples, toy blocks, then they learn abstraction with numbers.
When they get to high school they learn the x and y in Algebra 1... In college, some students may find themselves in the world of abstract algebra and operations.
In programming for the web, abstraction also takes place. we want to abstract the simple approach of HTTP and HTML with geneal data!

Enter XML: define you own tags. Everyone is excited about describing your data with your data.
If you let them do it they design wild XML files. Perhaps you have seen some very complex XML schemas and data files.
XML has grown into programming language like tools: XSL, to do all sorts of manipulation, and ANT, the ubiquitous build tool that modernizes batch file with XML. There are XML config files in every modern tool such as programming frameworks you encounter.

The idea of to tossing data, and not just HTML around the web is nothing new: DCOM, CORBA, EJB and all that. Things start to become outrageously complex. How come it cannot be simplified? Waita minute: why not simply use HTTP to pass XML around? Simple idea, but difficult to describe and implement.

So here is the buzzword: Web Services.
We need to specify the data being tossed around, and how is being toss around (enter SOAP). We need to describe the service that process the data (enter WSDL), and have some way to look up such service (enter UDDI)
These are all in XML, and they are complex. Don't let the word simple in SOAP mislead you.

These XML are so complex that it is almost impossible to write by hand. Fortunately, there are so many vendors and ever evolving tools to generate things for you.

Apache always provide useful and free open source tools for developers. Every server-side java developer should have Apache Tomcat to host servelets and jsps.
Enter Axis2: Apache's Web service engine. I was able to install and run some samples from the well writen guides. (Thanks Apache!)
Like J2EE calling EJB, calling a Webservice is not so intuitive. It ought to be more simplified.

My minor complain to Apache: the tools change so fast: Axis1 is totally obsolete. Axis2 is an entire new approach.

The web is revolutionary because of its simplicity. Type a URL: boom you got it,your browser will figure out how to render nicely.
The neatest part of the web is that it is somewhat tolerant: HTML missing a tag? no problem, though you don't see your page perfectly you
won't get a segmentation fault, NullPointerException or a freeze up.

WebServices has made programming more difficult. One mistake and you get a StackTrace of impossible to decipher error.
Actually, you can skip all that. Why not do you own data sending and prevent all the abstraction? Keep it simple is sometimes the best solution. Dear IT department: you may not actually need a Web Service.

1 comment:

bmalec said...

You should try creating/consuming some web services in .Net :)

At my previous job we were doing some web services in Java with Axis, and as you saw, it's a real pain in the butt. Microsoft's done a decent job implementing them in .Net, so it's pretty trivial to call web services.