Web Services

Archived Posts from this Category

Introduction to Web Services

Posted by Aurelio Pascual on 06 Nov 2006 | Tagged as: Java, Web Services

Web service is the latest buzzword in the field of distributed computing. It is a very important technology especially in the future of software engineering when Service Oriented Architectures (SOA) dominates the industry. Its popularity is mainly because of its simple and ubiquitous plumbing, programming language independence, use of open standards (XML, SOAP, etc.), and loose coupling. These are the characteristics that make web services a very important technology in today’s Internet age.

Web services evolved from prior technologies. The first technology on distributed computing was the client/server (C/S) technology. Client-server model started out as a two-tier application that later evolved as 3-tier termed as RPC (Remote Procedure Call). Then comes the Internet age, with all the different layers comprising a web application. A web application will usually comprise of many layers of application residing in one/many machines connected in a network. For example, a web application written in Java will constitute of a web server that connects to another application server running say a Servlet/JSP that connects to another application server running an EJB so on and so forth. But you may wonder, how these software components communicate. These software components communicate using what termed as Object Models. Object models because they use objects (I mean software objects in their own respective language) in communicating. For example, Microsoft uses the DCOM technology (Distributed Component Object Model), Sun uses RMI (Remote Method Invocation), OMG uses CORBA (Common Object Request Broker Architecture), so on and so forth. With the exception of CORBA, all of these technologies are language dependent. Although CORBA is language independent, it is still the same with others when it comes to difficulty in configurations and plumbing. With the emergence of Internet, massive number of software entities and devices are created and required to dynamically form massive number of networks with each other, and thus the birth of web services.

As I mentioned earlier, communication using web services is very simple because it uses open standards, it is language independent and is loosely coupled. No pre-configurations are needed in order to connect to a web service. The only contract that needs to be agreed upon between communicating parties is the syntax and semantics of the message to be passed.

A web service is also XML everywhere. The message is in the form of an XML and a web service is described in an XML called WSDL (Web Service Description Language). A WSDL is the heart of the web service and it’s the only thing you need in order for you to create a client.

To illustrate how simple a web service can be, below are the steps on creating a “Who Wants To Be a Millionaire” web service client using Eclipse WTP Project. The WSDL can be found on http://java.hlrs.de/glue-quiz/quiz.wsdl.

1. Download Eclipse WTP from this link: http://www.eclipse.org/webtools/ and extract it in your hard drive.

2. Open Eclipse WTP and create a new “Java Project”.


3. Download the WSDL of the service from this link: put-link-here and put it inside the project.

4. Right-click on the WSDL file and “Generate Client”. Eclipse will then generate the java files needed in order for you to create a client. Eclipse WTP uses Apache Axis WSDL2Java emitter in generating this client.

5. Create the main method of your client. It is advisable to put it in a separate class. Below is a sample.


6. Run the main method and enjoy your first web service experience!

Additional Note:

I noticed that the WSDL from the above example was changed since the last time I accessed it and the new WSDL is surprisingly not accurate.  The original WSDL uses “xsd:int” as the data type of the id element, but now its changed to “xsd:unsignedInt”.  Try changing it back to “xsd:int” in order for your WSDL to work.