Introduction to Web Services
This chapter introduces the basic web service concepts and standards.
1. Basic Concept of a Web Service
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.
-
Web services are self-describing.
To help web service clients understand the services, a web service publishes descriptions of its roles, functions, and properties.
Those descriptions are provided in a Web Services Description Language (WSDL) 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.
-
Internet open standard support
Web services support Internet open standards and are defined by industry agreed standards. As web services communicate based on universally agreed standards such as Simple Object Access Protocol (SOAP), WSDL, and Universal Description, Discovery, and Integration (UDDI), applications supporting web services are not faced with communication problems.
-
Platform and language independence
-
Application accessibility
Communication through web protocols like HTTP facilitates access to applications over the current security-heavy network environment with numerous firewalls.
2. Web Service Standards
With the release of Java 2 Platform, Enterprise Edition (Java EE) 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 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:
-
Implementing Enterprise Web Services (EWS)
-
Java API for XML-based Web Services (JAX-WS)
-
Java Architecture for XML Binding (JAXB)
-
SOAP with Attachments API for Java (SAAJ)
-
Streaming API for XML
-
Web Service Metadata for the Java Platform
-
XML, XML Namespace, XML Infoset, XML Schema
-
SOAP, MTOM, WS-Addressing
-
WS-ReliableMessaging, WS-Coordination, WS-AtomicTransaction
-
WSDL, WS-Policy, WS-MetadataExchange
-
WS-Security Policy, WS-Security, WS-Trust, WS-SecureConversation
The following sections describe some of the most commonly used standards among those listed above.
2.1. SOAP Standard
SOAP, which stands for Simple Object Access Protocol, is a lightweight, XML-formatted protocol used for exchanging information in distributed systems.
SOAP supports the following communication protocol.
-
Remote Procedure Call (RPC) protocol
RPC-style communication involves a request-response mechanism, where the client sends procedure-oriented messages to a service endpoint. The service endpoint processes these messages and returns appropriately constructed response messages.
-
Message-oriented communication
In message-oriented communication, the primary focus is on sending and receiving well-structured messages that may not necessarily correspond directly to remote method calls. This approach allows for processing service requests from the sender (client) without an immediate response requirement. Message-oriented communication is particularly useful for exchanging various formats of documents in business scenarios, making it well-suited for scenarios where data exchange takes precedence over immediate interactions. Due to its emphasis on exchanging documents, this communication style is often referred to as document-style communication.
The SOAP protocol consists of the following elements.
-
SOAP message envelope
The SOAP message envelope contains information about how messages are processed, who processes them, and it also envelops the body of the message.
-
Encoding rule for describing application data type objects
-
Other requirements for representing remote procedure calls and responses
The following describes the characteristics of SOAP.
-
Protocol neutrality
-
Language independence
-
Platform and OS independence
-
SOAP XML messages can include additional content or attachments by using standards like MIME.
2.2. WSDL Standard
The Web Service Description Language (WSDL) is used to describe RPC-style 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.
2.3. UDDI Standard
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.
2.4. JAX-WS, JAXB, StAX Standards
Java API for XML-based Web Services (JAX-WS) standard defines the web service API provided by Sun Microsystems. 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.
3. SOAP Message Exchange and Encoding
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 both RPC-style and document-oriented (message-oriented) communications.
-
RPC style communication
RPC style communication means 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 communication
In document-oriented communication, 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.
-