O'Reilly logo

Java SOA Cookbook by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Web Services with SAAJ

Introduction

This chapter examines how to build Java clients that can talk to SOAP-based web services using the SOAP with Attachments API for Java (SAAJ) API.

SOAP, standardized by the W3C in 2000, is a platform-agnostic way of creating and sending messages in a distributed system.

Note

You may be familiar with SOAP as an acronym for Simple Object Access Protocol, but version 1.2 of the spec, published in 2003, throws out the explanation of the acronym with the direct, clear, and yet mysterious statement that “This is no longer the case.” Perhaps they decided it wasn’t so simple after all….

Because SOAP is based on XML, it is relatively easy for humans to read and understand, and the structure of a SOAP message itself is simple. SOAP messages are always wrapped in a container called the envelope; the envelope always contains a body, which carries the payload of the message in one or more XML documents. Optionally, your envelope can include headers, very similar to HTTP headers. If something goes wrong during processing, a SOAP fault will be added as the body content. The structure of a SOAP 1.1 envelope is depicted in Figure 5-1. The * in the figure denotes that there can be multiple instances of that type.

Structure of a SOAP envelope

Figure 5-1. Structure of a SOAP envelope

Developers on either end of the web service can extract the content of the SOAP envelope using XML tools for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required