Table of Contents
This chapter introduces the basic web service concepts and standards.
A web service is a standardized technology that enables applications to communicate with each other regardless of the platform and programming languages used, and the software interface that implements network access by using the standard XML messaging protocol. In addition, just with an Internet connection, a web service makes businesses available to any user with authority to use the service. For its use, it also defines a convenient environment for the messaging protocol, programming standard, and discovery service.
A web service is an application program that can be accessed through a URI over the Internet. Its interfaces and bindings can be defined and described by XML artifacts. A web service not only communicates with other web services published on the Internet, but it can also communicate with legacy back-end applications.
Until recent years, every application architecture was classified into two major types. One is a single tier mainframe-based system, and the other is a two tier client-server architecture running on a desktop. These architectures are tightly coupled and lack extensibility. Since programs within these architectures are too restricted and difficult to access, they are not useful for users on the web.
This limitation steered the software industry toward Service-Oriented Architecture (SOA), which enables application programs to dynamically communicate with each other on the web. The application programs drove software systems to be divided into modularized sub-systems, and the sub-systems have been implemented using various technologies. They do not need to exist in a single computer, and can also be reused. They are also designed to be accessible to any user on the web through the use of standard web protocols such as XML and HTTP.
SOA is not a new concept. It has been implemented from years ago in many different forms including RMI, COM and CORBA. However, these technologies are either vendor-specific or technology-specific, which prevents them from being universally adapted. Web services have been designed to overcome such shortcomings.
The following are the features of Web services.
Web services can be invoked over the Internet.
To help web service clients understand the services, web service publishes descriptions of its roles, functions, and properties in a WSDL (Web Service Description Language) file to allow external applications to be able to locate and utilize the web service.
Web services communicate with the clients through XML based messages via standard Internet protocols like HTTP. Web service clients can be any application or another web service.
The operation type of a web service is either request-response or one-way, and the service is invoked through either synchronous or asynchronous communications. Regardless of the operation type and communication, the basic unit of data exchanged between web services and web service clients is a message.
The following are the advantages of Web services
Supports Internet open standards and is defined by industry agreed standards. As web services communicate based on universally agreed standards such as SOAP (Simple Object Access Protocol), WSDL, and UDDI (Universal Description, Discovery, and Integration), applications supporting web services are not faced with communication problems.
Platform and programming language independent.
Communicates through web protocols like HTTP, making it easy to communicate through the current security-heavy network environment with numerous firewalls.
With the release of Java EE (Java 2 Platform, Enterprise Edition) specification version 1.4, web services became a significant part of Java EE standard. Services including transaction support, database connection, and life cycle management can now be supported without modifying the program source code.
To provide better web services, new specifications have been added to Java EE (Java Enterprise Edition, the new name of J2EE) version 5, and the functions of existing specifications have been re-organized and improved.
The following are the standards that the current JEUS web services must conform to.
The following sections describe some of the main standards.
SOAP (Simple Object Access Protocol) is a lightweight XML-based protocol used to exchange information in a distributed environment.
The following are the supported information exchange methods.
RPC (Remote Procedure Call)-oriented exchanges
A RPC-oriented exchange allows for request-response processes, where as an endpoint service receives a procedure oriented message and replies with an appropriate response message.
Message-oriented exchanges
Message-oriented exchange must be used when the sender does not need an immediate response for a message sent. It's generally used to exchange business or other types of documents. It's also called a Document-oriented information exchange.
The following are the elements of the SOAP protocol.
An envelope that describes the SOAP message.
The envelope contains the body of the message and describes who and how to process it.
A set of encoding rules for expressing instances of application-specific data types.
A convention for representing remote procedure calls and responses.
The following are the features of SOAP.
Protocol independent
Programming language independent
Platform and operating system independent
Support for attaching MIME type messages to SOAP XML messages
The Web Service Description Language (WSDL) is used to describe RPC-oriented and message-oriented network services in XML format. Development tools, service developers, or deployers (service providers) can create WSDL files. If the files are opened on the Internet, the service is exposed to other clients which creates an environment where the clients can also access the service.
Client-side programmers and service consumers can use the published WSDL descriptions to obtain information about the available web services. Based on the information, they can create proxies or program templates to access the services.
The Universal Description, Discovery, and Integration (UDDI) specification defines a standard way to open and search for web service related information. A service provider saves its services in the UDDI, an online repository that is already known to the service consumers, and the consumers access the repository to search for desired list of services.
JAX-WS(Java API for XML-based Web Services) standard defines the web service API provided by Oracle. As the successor to JAX-RPC standard, JAX-WS is a new enhanced integration of JAXB standard for XML binding, StAX standard for standard streaming parsers, and improved SAAJ standard. By using JAX_WS, all of the descriptor files, which have been requested by Java EE 1.4 specification, can be replaced by the annotation function of Java SE 5.
JAX-RPC (Java API for XML-based RPC) is a Sun Microsystems specification that defines the web service API. One of the challenges of web services that needs to be resolved is interoperability. Various standard organizations, including WS-I, OASIS, W3C and SOAPBuilders, have been making numerous efforts to resolve this problem.
JAX-RPC is the result of the first efforts made by the Java Camp for J2EE 1.4 specification to resolve the interoperability problem and provide flexible programing API for web service implementation. JAX-RPC has removed a huge burden of interoperability from service users and developers through the runtime framework. The framework later advances to JAX-WS, a framework for web services.
SOAP supports RPC and document-oriented methods for exchanging messages. SOAP uses the encoding mechanism configured as the EncodingStyle attribute for the SOAP message element.
This section describes the characteristics of a SOAP message.
SOAP Message Composition
A SOAP message has a SOAP envelope, and the envelope has two sub-elements: header and body. The header is optional, and its sub-elements, header blocks, may be seen as logical sets of data. The SOAP body, an essential element of a SOAP message, contains the contents of the actual message that needs to be delivered.
SOAP Message Encoding
SOAP supports RPC and Document-oriented message exchanges.
RPC-oriented Information Exchange
RPC-oriented method refers to the method of exchanging messages through a remote procedure call. Client and server programs should be implemented with well defined programming model. The client calls a method with arguments, and the server returns a value as a response. For RPC-oriented exchanges, SOAP defines a separate body structure for the message.
Document-oriented Information Exchange
For Document-oriented information exchanges, XML documents are exchanged and the definition of the XML elements are left to be interpreted by the server and client. Thus, SOAP does not define any message body structure for Document-oriented exchanges. The XML message structure is defined by a separate XML schema or by the application itself.