Java Reference
In-Depth Information
We b services are so important that Sun now provides many Java libraries to
support web services development with Java. The entire package is available as
one (large) add-on to the standard Java installation. The package is called the Java
We b Services Developer Pack, or JWSDP, and includes a variety of technologies,
only a few of which we discuss here [8, 9].
21.4.1 Java servlet technology
Before web services, there was the World Wide Web, which delivered static
HTML documents to web browsers over the Internet using the hypertext transport
protocol (HTTP) to send data back and forth between client (i.e. browser) and
web server. Soon it was learned that people needed to provide information to
web servers, not just read static web pages. HTTP includes the GET and POST
methods that provide information to web servers. When you do a web search
for instance, you're probably using, behind the scenes, a GET operation. When
you fill out a form at an online merchant providing your name, shipping address,
billing information, etc. you're almost certainly using POST. All this happens
completely transparently to the user.
Then it was realized that web servers needed to be able to generate dynamic
content, and thus was born the common gateway interface (CGI), which provided
away for web servers to send data to an external program - often written in perl
orC-toperform some calculations and generate HTML pages dynamically.
To resolve some performance problems with CGI, Sun introduced the Java
servlet technology with which a web server can quickly execute Java code to
generate dynamic content (see also Section 14.8). The Java code that is exe-
cuted by the web server is called a Java servlet [10]. It must be written in a
special way to be a servlet, much like Java applets must be written to extend
java.applet.Applet . The part of the web server that deals with Java servlets
is called a “servlet container.” The reference implementation of a servlet container
is an open-source product called Apache Tomcat [11]. Tomcat can be used in con-
junction with the standard Apache web server or it can be run standalone as both
aweb server and a servlet container. JWSDP includes support for Tomcat, but
Tomcat itself is a separate download from http://jakarta.apache.org .
21.4.2 Java servlets for web services
So what do Java servlets have to do with web services? The answer is that perhaps
the simplest way to implement a web service is with Java servlets! Servlets process
HTTP GET and POST operations. In the most basic web services paradigm, XML
documents are sent from the client as the payload of a GET or POST operation,
and Java servlets running on the server receive that XML payload. Then, within
the servlet, an XML parser processes the payload, feeding the various parameters
to calculations to be performed by the server. In a standard servlet, the servlet
Search WWH ::




Custom Search