Home > Articles > Programming

The Quickest Route To Implementing Web Services

  • Print
  • + Share This
Merrick Stemen looks at the fastest, easiest way to program web services and offers examples implemented in the Water language. This article compares a Water language web server program with the equivalent Java programming.
Like this article? We recommend

Despite having taught programming and computer science for more than 15 years, I'm still amazed sometimes; for example, when I discovered that I could do NetBIOS programming in FORTH, CGI scripts in FORTRAN, or an SMTP client in COBOL. (I was even amazed that I could actually write new games for the Mattel Intellivision game system.)

For programming web services, the biggest surprise has been the Water language and the Steam XML IDETM, the Water development environment and runtime engine by Clear Methods, Inc. of Cambridge, Mass.

The Discovery of Water

The thing that first attracted me to Water was a write-up in eWeek magazine describing Water as an answer to what the founders at Clear Methods considered to be some serious shortcomings in XML 1.0, and their suggestions for creating a language that was specifically written to deal with XML and web services. I downloaded the demo, and I was hooked.

Because I compulsively explore each new language I run across, I immediately began to devour every scrap of Water documentation I could find. I joined the Water language discussion group at Yahoo! and visited every link from Waterlanguage.org. I started writing short demo programs, trying out feature after feature, but my favorite feature is the ease with which you can turn any Water program into a web service.

Because Water is a language for web services, giving the programmer the ability to create a web service with a minimum of code is a priority. Here's a quick example. Suppose you want to deploy a web service that provides a random number from 1 to 20 (inclusive) to clients. In Water, the function might look like this:

<defmethod get_random >
  20.<random_number />.<plus 1 />
</>

In other languages, adding the functionality to allow someone to access that random number from a web browser client would add many lines of code to the simple random-number generator. In Water, you would simply add this line:

<server get_random port=5656 />

And voilà! Just point your browser at http://localhost:5656/?, and the random number comes right to the browser. No Apache web server, no Microsoft IIS—just Java and Steam XML.

With the new random-number server application on my machine, anyone who can access the machine across the network can get a random number. Even other applications can obtain the random number. Anyone else running Water on their machine could point at my machine to get random numbers for their programs just by adding this line:

<set a_random_number=<web "http://mstemens_machine:5656/?" />.result />

Very cool.

An equivalent program written in ASP or PHP might be as short as this one, but try running the ASP or PHP application on a machine that doesn't have a web server already on it. It just isn't going to work.

  • + Share This
  • 🔖 Save To Your Account