# SOAP

SOAP (formerly known as Simple Object Access Protocol) is a lightweight protocol for the exchange of information in a decentralized, distributed environment. A SOAP message is a transmission of information from a sender to a receiver. SOAP messages can be combined to perform request/response patterns.

SOAP is transport independent but is most commonly carried over HTTP in order to run with the existing Internet infrastructure. SOAP enables the binding and usage of discovered Web services by defining a message path for routing messages. SOAP is used to query UDDI for Web services. The workbench supports SOAP 1.1.

SOAP is an XML-based protocol that defines three parts to every message:

- Envelope. The envelope defines a framework for describing what is in a message and how to process it. A SOAP message is an envelope containing zero or more headers and exactly one body. The envelope is the top element of the XML document, providing a container for control information, the address of a message, and the message itself. Headers transport any control information such as quality-of-service attributes. The body contains the message identification and its parameters. Both the headers and the body are child elements of the envelope.
- Encoding rules. The set of encoding rules expresses instances of application-defined data types. Encoding rules define a serialization mechanism that can be used to exchange instances of application-defined data types. SOAP defines a programming language-independent data type scheme based on XSD plus encoding rules for all data types defined according to this model. SOAP encoding is not WS-I compliant and thus the Literal use (which is no encoding) is suggested for interoperable Web services and required for WS-I compliance.
- Communication styles. Communications can follow a remote procedure call (RPC) or message-oriented (Document) format. These are discussed below.

#### Binding styles

SOAP supports two different communication styles:

> Remote procedure call (RPC): Invocation of an operation returning a result. Typically used with SOAP encoding, which is not WS-I compliant.

> Document Style: Also known as document-oriented or message-oriented style. This style provides a lower layer of abstraction, and requires more programming work.

#### Encoding styles

In distributed computing environments, encoding styles define how data values defined in the application can be translated to and from a particular protocol format. The translation process is know as serialization and deserialization.

The SOAP specification defines the SOAP encoding style:

> SOAP encoding: The SOAP encoding style allows you to serialize/deserialize values of data types from the SOAP data model. This encoding style is defined in the SOAP 1.1 standard, and is not WS-I compliant.

WSDL defines the Literal XML encoding style:

> Literal XML: Literal refers to the fact that the document should be read as-is, or unencoded. The document is serialized as XMI, meaning that the message XML complies with the Schema in the WSDL. When using Literal encoding, each message part references a concrete schema definition. Literal encoding is WS-I compliant.

#### Data model

The purpose of the SOAP data model is to provide a language-independent abstraction for data types used by common programming language types. It consists of:

- Simple XSD types. For example int, string, and date.
- Compound types. There are two kinds of compound types, structs and arrays. Structs are named aggregate types in which each element has a unique name or XML tag. Arrays have elements that are identified by position, not by name.

All elements and identifiers comprising the SOAP data model are defined in the namespace URI. The SOAP standard defines the rules for how data types can be constructed. A project specific XML schema must define the actual data types. The elements of the SOAP specification are defined in http://schemas.xmlsoap.org/soap/envelope/ and http://schemas.xmlsoap.org/soap/encoding/

#### SOAP implementations

Different implementations of the SOAP protocol are available today. For example, the Apache Foundation provides Apache SOAP, which grew out of an IBM® project called SOAP4J, as well as Apache Axis and the IBM WebSphere® runtime environments.

#### Mappings

A mapping defines an association between a qualified XML element name, a Java™ class name, and an encoding style. The mapping specifies how, under the given encoding, an incoming XML element with a fully qualified name is converted to a Java class and vice versa.

For more information on Apache SOAP, refer to xml.apache.org/soap For more information on SOAP refer to www.w3.org/TR/SOAP

Parent topic: Web services standards
Related Concepts
Web services overview
Tools for Web services development
Related Tasks
Developing Web services