The Role of SOAP in XML Web Services                                         

SOAP provides a standard XML-based message format to represent a method call and its response. By
design, SOAP is a very simple spec. The SOAP body contains the information required to execute the
method call such as its name and the parameters. The SOAP header contains other ‘out-of-bound’ data such
as security or transaction information. The header section is optional. The SOAP envelope encapsulates the
body and the header.















For example, here is a simple method and the corresponding SOAP message to call it.


[WebMethod]
public int Add(int n1, int n2)
{
 return n1 + n2;
}




<soap:Envelope xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
           xmlns:soap = "http://schemas.xmlsoap.org/soap/
                         envelope/">
<soap:Body>
<Add xmlns = "http://intertech.com/">
  <n1>
int</n1>
  <n2>
int</n2>
</Add>
</soap:Body>
</soap:Envelope>


The return SOAP message looks like this:


<soap:Envelope xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
           xmlns:soap = "http://schemas.xmlsoap.org/soap/
                         envelope/">
<soap:Body>
<AddResponse xmlns = "http://intertech.com/">
  
<AddResult>int</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>


Unless you need to tweak or extend the format of the SOAP information, both XML web services and WCF
will take care of the details automatically. Moreover, based on which binding options you support (security,
transaction, reliable messages, and so on), WCF will update the SOAP data accordingly. WCF does allow you
to alter the format of a SOAP message using various ‘message attributes’. Messages attributes will be
introduced later in this course.
SOAP in XML Web Services
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services