Java Tutorial - Java Scipt : A Brief Introduction to Web Services and SOAP

Java Tutorial - Java Scipt :

A Brief Introduction to Web Services and SOAP

When people think of Web services, SOAP is usually the standard that comes to mind. SOAP (Simple Object Access Protocol) is an XML-based invocation protocol whose success is due in large part to its simplicity. Essentially, SOAP offers the same functionality of remote procedure calls (RPCs).

Platform and language independence are two of the key SOAP design goals. This approach is validated by the widespread support from major companies for SOAP. AJava Web services client can interact with a Web service hosted on a Microsoft .NET server just as easily as one on Apache Axis. Tangible benefits are realized by the standardization of open protocols such as SOAP.

Again, harking to the goal of simplicity, SOAP is much more loosely coupled than previous RPC standards. As with the case of scripting, loose coupling makes SOAP easy to use at the expense of strict checking and language integration. Apache Axis, with its stub-generation capability, brings back those benefits by building stubs on top of the SOAP layer.

Another important point is that SOAP is not actually tied to any single transport protocol, although most deployments use HTTP. In theory, this flexibility is a good separation of design. Unfortunately, this leaves key issues like session management and transaction support up in the air. Many vendors have forged on ahead with proprietary implementations for the time being.

Figure 11.1 shows the basic structure of a SOAP message:

For the most part, we can focus our attention on the SOAP body. The SOAP headers are usually generated for us by the APIs we’ll be using. Also, note that the AttachmentPart sections are an extension to the basic SOAP message that is covered by the SAAJ API (see the definition of SAAJ in the upcoming list).

Figure 11.1  Structure of a SOAP message.

Despite all its fame, SOAP alone is not enough to create a useful Web services ecosystem. It is mostly just an invocation protocol, and there is a need for many other standards for things such as discovery, description, and standardized schemas. In addition to SOAP, a number of standards are either in use or being pushed as solutions to the higher-level problems faced by Web services. These include the following standards:

BPELWS.  Business Process Execution Language for Web Services enables complex business conversations and workflows, a critical next step for Web services.

ebXML.  Electronic Business Extensible Markup Language is a set of specifications covering electronic business. The Java APIs that implement approved standards include JAX-RPC, JAXM, and JAXR.

JAX/RPC.   This is the most important Java API, because it handles the binding between the underlying language-independent protocols, such as SOAP and WSDL, to Java objects and interfaces.

JAXM.  Java API for XML Messaging implements the SAAJ API and extends SOAP with additional functionality

JAXR. Java API for XML Registries is used to access various Web service registries, those specified under the umbrella of UDDI (Universal Description, Discovery and Integration) and ebXML.

SOAP. This is the invocation protocol for using Web services.

SAAJ. SOAP with Attachments API for Java is the Java API for working with SOAP messages that have additional MIME (Multipurpose Internet Mail Extensions) data attached.

UDDI. Universal Description, Discovery and Integration of Web services is a discovery mechanism that lets clients find Web services in a public directory.

WSDL. Web Services Description Language governs the description of a Web service and how to use it.

XML Schema. This is the schema description of cross-platform data types used in SOAP messages.

The Java Web Services Developer Pack (JWSDP), available at the following URL:

contains the reference implementations of the Java standards mentioned here. These APIs will be required of future J2EE 1.4–compliant application servers. Until then, it may be necessary to download the JWSDP for some of the

Most industry heavyweights already support SOAP, and it will very likely be a linchpin of the new Web landscape. Web services will continue developing upon and around SOAP.