Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 2.11

Introduction SOAP (Simple Object Access Protocol)

This chapter describes:

  • What is SOAP?
  • A SOAP communication example.

What Is SOAP?

SOAP is an XML based protocol intended for exchanging structured information in a distributed application environment.

SOAP 1.2 specification is divided into two parts.

SOAP part 1 defines the SOAP messaging framework, which contains the following key concepts:

  • SOAP Message Construct - How a SOAP message should be constructed.
  • SOAP Protocol Binding Framework - How a SOAP message should be bound a communication protocol to carry it from the sender to the receiver.
  • SOAP Processing Model - How a SOAP message should be processed by SOAP receivers.
  • SOAP Extensibility Model - How SOAP can be extended to add SOAP features and SOAP modules.

SOAP part 2 defines a set of adjuncts that can be used to extend the SOAP messaging framework:

  • SOAP Data Model - How data structures and values should be represented as a graph of nodes.
  • SOAP Encoding - How data presented in SOAP Data Model should be encoded as XML data.
  • SOAP RPC Presentation - How Remote Procedure Call (RPC) should be modeled with SOAP.
  • SOAP Convention for Describing Features and Bindings - How SOAP Features and Bindings should be described.
  • SOAP Supplied Features - Commonly used SOAP extensions.
  • SOAP HTTP Binding - How a SOAP message is bound to HTTP.

SOAP is actually a communication protocol that defines how a message should be constructed, transmitted from one node to another, and processed by each node as shown in the following diagram:

SOAP node          
 |
 | Construct an initial SOAP message
 | Bind the initial message for transmission
 | Transmit the initial message
 v
 ----------> SOAP node
              |  
              | Receive the initial message
              | Process some part of the initial message
              | Reconstruct an intermediate SOAP message
              | Bind the intermediate message for transmission
              | Transmit the intermediate message
              v
              ----------> SOAP node
                           |
                           | ...
                           v
                           ----------> SOAP node 
                                        |
                                        | Receive the final message
                                        | Process the final message
                                        v
                                        Done 

SOAP Communication Example

Before going into details of the SOAP specification, let's try a very simple SOAP example. There are 3 basic steps involved in a SOAP communication:

1. Creating a SOAP message. This is easy. Just use any text editor to enter the following SOAP message, hello.msg:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 <env:Header>
  <h:control xmlns:h="http://herong.com/header">
   <h:sender>Herong</h:sender>
  </h:control>
 </env:Header>
 <env:Body>
  <b:greeting xmlns:b="http://herong.com/body">
   <b:msg>Hello there!</b:msg>
  </b:greeting>
 </env:Body>
</env:Envelope>

2. Transmitting the message from a SOAP node, my machine, to another SOAP node, your machine. A simple way to do this is for me to send hello.msg to you as an email, so you will get something like this:

From: herong@my.com
To: you@your.com
Subject: Greeting

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 <env:Header>
  <h:control xmlns:h="http://herong.com/header">
   <h:sender>Herong</h:sender>
  </h:control>
 </env:Header>
 <env:Body>
  <b:greeting xmlns:b="http://herong.com/body">
   <b:msg>Hello there!</b:msg>
  </b:greeting>
 </env:Body>
</env:Envelope>

3. Processing the message. Once you got my SOAP message, you should be able to read it, and do whatever you want to do with it.

Dr. Herong Yang, updated in 2006
Herong's Tutorial Notes on Web Service and SOAP - Introduction SOAP (Simple Object Access Protocol)