This chapter will cover the evolution of network computing, an overview of how the web service model came to be, the definition of web services, its properties and and what states or sce
Trang 11 Introduction to Web Services
1.1 Objectives
Towards the end of the chapter, you should be able to learn the following:
• Determine what web services are
• Identify the characteristics of a web service and how it works
• Point out the need for web services
1.2 Introduction
The domain of web services is an emerging technology due to the growing demand of application-to-application communication and interoperability The reason for its popularity is because of its flexible nature, since it exhibits itself as a standard interface which is not only platform-independent but technology independent as well We'll talk more about this later
This chapter will cover the evolution of network computing, an overview of how the web service model came to be, the definition of web services, its properties and and what states or scenes are they applicable to And lastly, the discussion of the current status of web services and where it is heading
1.3 How did web services came to be? (A History of Distributed Computing)
During the prehistoric era in software services, computer programs were written in assembly and are executed using single memory space (see Figure 1) The software's subroutines communicate digitally using the machine's registers Programmers during this time find it hard to write, more so, maintain codes
Shortly after assembly, came procedural languages such as COBOL, C and FORTRAN, which allowed programs to be written more easily than their forerunner since they resemble more the human language Moreover, these procedural languages allow programs to run on different machines The software service during this time were functions that were directed by the use of control structures Although this is a technological advancement in computing, it is no different with assembly in the sense that programs are executed in single memory space
Trang 2Figure 1 Communication in single memory space in the same computer
The next generation was the development of network computing, wherein, instead of communicating through magnetic tapes, the exchange of information became real-time TCP/IP network protocol and the C programming language became the “in” thing back then This was made possible by the invention of RPC (Remote Procedural Call) which allows software services to invoke each other the network (see Figure 2) This effectively broke the chain that holds back software services within the bounds of individual machines to collaborate in a larger scale
Trang 3Figure 2 Functions communicating between memory spaces using RPC
After procedural calls came the time of functional languages such as LISP, followed shortly
by object-oriented languages such as C++ and of course, Java The development of object
oriented language allowed developers to create objects, which are real world counterparts If you
haven't noticed, objects are in truth software services
More sophisticated network protocols were discovered by this time The most popular ones are CORBA (Common Object Request Broker Architecture) and DCOM (Distributed Common Object Model) These two will not be expounded as they are not within the scope of this course material, but suffice to say that they are network protocols that grants connection between software services The limitation of using the said protocols was that the deployment of these technologies were homogeneous in nature Homogeneous meaning, they are deployed in closed environments
The following was the case until the invention of the Internet Thanks to the Internet, geographical barriers started to blur and businesses began to flourish by taking advantage of this wonderful innovation Eventually, people began to see the power of distributed computing and the promise it shows
1.3.1 Communication Patterns
Two things sparked the start of web services the evolution of distributed computing and the revolution in the way we think about building large scale systems As a recap from the previous courseware, web applications, we know that distributed computing1 is as the definition below says,
1 http://en.wikipedia.org/wiki/Distributed_computing
Trang 4A very good example of a distributed system is the World Wide Web (WWW) As you are surfing the Internet, you might not realize it but, you are in reality, using distributed system Your web browser is communicating with other web servers providing the web pages you visit Your web browser talks to various web servers over the Internet via a system of routers, which are themselves part of a bigger distributed system The aim of distributed computing is to find a way to connect users and resources in an open and scalable way Before this goal was met, various computing obstacles were encountered and eventually as these impediments are overcome, the computing industry began to mature
The next section gives a blow-by-blow series of event leading to the design of web services The illustration below (Figure 3) shows how distributed computing evolved from a simple client server model to what is expected of it in the future Web services lies pretty much in the middle of it
Figure 3 2
2 “Web Services Overview.” Web Service Programming (with Passion!) Sang Shin
<http://www.javapassion.com/webservices/index.html#Web_Services_Overview>
Distributed computing is parallel computing using multiple independent
computers communicating over a network to accomplish a common objective
or task The type of hardware, programming languages, operating systems
and other resources may vary drastically
Trang 5Evoution of Communication Patterns
In the beginning, there was the client-server model (see the first image from the left of Figure 3) If you would recall in the web programming module, in a client-server communication pattern, there are two entities involved, the client, which we could think as the person and his computer, requesting for a certain resource from the server (limited to the name of a document needed or a call to a server-side program), and the server, which returns the information requested
Figure 4 The consumer fetches information through HTML and a protocol
Figure 4 is to look at the client-server model in finer detail The graphical representation shows that clients or consumers requests information from the server, which in turn processes the requests and throws back a web page containing information requested by the client/consumer Remember that this is done through the use of HTML and a network protocol such as HTTP Although the client-server communication pattern made it easy for consumers to access web pages, still that is not enough to integerate business systems more flexibly Thus, the introduction
of the 3-tier communication pattern
In the web application courseware, you are taught about the MVC framework, which is in
particular, the Model, View and Controller It is a matter of fact a 3-tier communication pattern A
3-tier communication pattern is a client-server model wherein the user-interface, a functional process logic, and a computer data storage are developed and maintained as autonomous modules The illustration below shows the 3-tier communication pattern
Trang 6Figure 5 The 3-tier communication pattern
From 3-tier communication pattern, it evolved to the web application communication pattern (Figure 6) The web application communication model (J2EE architecture) is comprised of
a web server, application server and a database server On the other hand, J2SE and J2ME is responsible for the client tier I wouldn't linger more on this topic since it was disucssed in detail
in the previous courseware As a matter of fact, the web service course assumes that you have knowledge about web applications before moving on further
Moving on, an improvement to the web application communication pattern is the web services communication model (Figure 7), which is what this course is all about The picture shows the technolgies in which a lot of business organizations and industries could leverage on
Trang 7Figure 6 3
Web application as communication pattern
3 “Web Services Overview.” Web Service Programming (with Passion!) Sang Shin
<http://www.javapassion.com/webservices/index.html#Web_Services_Overview>
Trang 8Figure 7 4
Web Services as Communication Pattern
Due to the attributes stated above, various software services are not confined to interacting with their kind, such as the what is shown in Figure 8
Figure 8 Software service interaction through the use of web service
The web service model above shows that a web service exhibits the application logic, also known as the application function of one communication participant (can be thought of as the server) to multiple or heterogeneous client base (such as cellphone, PDA, and other types of clients) independent of its object model implementation, programming language or runtime environment This functionality is what distinguishes web services from other remote access mechanisms like Remote Method Invocation (RMI), and CORBA
Having said the these, the web service infrastructure can be view as though each of the participants can act as both user and provider of service This means that, information can be retrieved from a PDA by a cellphone, a laptop to a swing client and vice versa Having said all these, let us go to the formal definition of what a web service is
1.4 What is a web service?
When you look around the Internet and various reading materials, you must have concluded that there's a lot of hype, and marketing talk about it Not much of these materials can
be of use to developers And even today, it is hard to grasp a consistent definition for what it really is The most reasonable definition I came up with my research is that from the World Wide
4 “Web Services Overview.” Web Service Programming (with Passion!) Sang Shin
<http://www.javapassion.com/webservices/index.html#Web_Services_Overview>
Trang 9Web Consortium (W3C)5 The said governing body defined web service as follows:
Don't worry if you find the said definition a little overwhelming You'll be able to understand and appreciate it as we go along the rest of the chapters For now, think of web service as a software application available over the web that is accessed by clients using XML-based protocols For starters, you can look at the site http://www.xmethods.com The said site contains a handful of web services which are implemented using different technologies At the time of my visit, I found the following listing:
Figure 9
5 http://www.w3c.org/TR/ws-arch
“ a software system identified by a URL, whose public interface and bindings
are defined and described using XML Its definition can be discovered by other
software systems These systems then interact with the web service in a manner
prescribed by its definition, using XML based messages conveyed by Internet
protocols.”
Trang 10Sample Web service listing
The listing above won't exactly bring you to the service itself But you will be sent to a page saying where to get the service that you want and who to contact for more information To
be able to connect to the service being offered on the page, you need to create a client application, which we will be discussing in the succeeding chapters Suffice to say that these services are free, and you only need a web browser and an Internet connection
1.5 Why Web Services?
You must be thinking, what's so special about web services that HTML, JSP and other
technologies cannot accomplish? An example presented in the book, Java Web Services in a
Nutshell (A quick desktop references) 6 , presents the situation where a certain publisher wants to
keep track of the sale of books He has three options to go about this:
1 Use the site's search facility to locate a few titles, read the review To go about this, each stage entails rendering HTML, and answering or clicking a form Obviously, this option is too tedious to do, bordering insanity
2 Write a code that extracts information from HTML This means that the application will strip the HTML and get the raw data This idea is better than the first one since it has some level
of automation into it Although still not cost efficient since, you only need the figure of the sales ranking of the book, to bother with the program Apparently, this is still not the best solution since the layout of the HTML can change, thereby rendering the program invalid
3 The obvious choice is the use of web services Amazon can provide a web service interface and expose the appropriate information in XML form The publisher only need to write a client program to retrieve information from the web service Through web services, the publisher won't have to deal with markup, but instead go straight to data he/she needs As
a matter of fact, Amazon really did that in the middle of 2002 Another advantage of using web services is that with the retrieved information from the service, the publisher can customize how the data is displayed to his/her own format and not conform with that of Amazon's web page
In addition to the advantages presented by the scenario, here are the other reasons why web services is very appealing:
• XML-based – using XML rids any networking, operanting system, or platform binding
dependency that a protocol may have As a data representation layer, XML allows for iteroperability at the core level We will talk about XML in detail in the next lesson
• Loosely-coupled – the attribute of beind loosely-coupled could only be equated with
versatility, in the sense that a consumer of a web service is not bound to that web service directly This means that, say the service interface changes, the client need not adopt to the changes made Being loosely-coupled makes software systems more manageable
• Coarse-grained – perhaps the best way to explain this attribute is to first show what the
opposite of it – fine-grained, means A Java program has methods, and these methods have specific tasks These methods carrying-out specific jobs are fine-grained methods
So, when we build a Java program from scratch, we are therefore making a lot of
fine-6 Topley, Kim Java Web Services In a Nutshell O'Reilly & Associates, Inc June 2003