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.
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.
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 ...