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

SOAP Communication Example

This section describes an simple example of SOAP communication.

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.

Last update: 2007.

Sections in This Chapter

What Is SOAP?

SOAP Communication Example

Dr. Herong Yang, updated in 2009
SOAP Communication Example