TechBubbles Microsoft Technology BLOG

SOAP Fundamentals

Introduction

SOAP is  a protocol to exchange the XML messages over the network using HTTP\HTTPS.It stands for Simple Object Access Protocol.It is platform and language independent.

SOAP Building Blocks

A SOAP Message is an XML Document contains the following elements

  • Envelope element which identifies the XML document as a SOAP Message.It is required element in SOAP message.
  • Header element which contains the header information which is an optional element.
  • Body element contains the request and response information which is a required element in SOAP.
  • Fault element contains the error information during the processing of a message.

SOAP Message Syntax

<?xml version="1.0"?>
<soap:Envelope
//Must contain SOAP envelope namespace
xmlns:soap=http://www.w3.org/2001/12/soap-envelope 
//Must use SOAP encoding namepace
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  <soap:Header>
</soap:Header>
  <soap:Body>
  <soap:Fault>
  </soap:Fault>
</soap:Body>
</soap:Envelope>

 SOAP Envelope

  • Namespace: Root element of SOAP message is Envelope it defines the XML document as a   SOAP message. It should always contain the name space http://www.w3.org/2001/12/soap-envelope.
  • Encoding Style Attribute: Used to define the data types used in the XML document. It has no default encoding.

SOAP Header

The Header element in SOAP contains the authentication information or information about ongoing transaction.

Example:

    <soap:Header>
      <h:PServer xmlns:h='http://example.org/cvs/pserver'
               soap:mustUnderstand='true' >
      <username>guest@test.org</username>
      <password>guest</password>
     </h:PServer>
   </soap:Header>

Each header element may be associated with a mustUnderstand attribute. We can set true or 1 value for this attribute then it considered to be mandatory. If the recipient of the message failed to recognize then it must generate a SOAP fault message.

SOAP Body

The SOAP Body element contains the actual SOAP Message intended for the recipient. SOAP defines one element inside Body element which is SOAP Fault element used to indicate error messages.

Example:
<soap:Body>
   <m:GetPrice xmlns:m="https://www.techbubbles.com/prices">
      <m:Item>Mobile</m:Item>
   </m:GetPrice>
</soap:Body>
The Example request the price of mobile.
The SOAP Response could looks like 
<soap:Body> 
<m:GetPriceResponse xmlns:m="https://www.techbubbles.com/prices"> 
<m:Price>Mobile</m:Price> </m:GetPriceResponse >
</soap:Body>
SOAP Fault
This is an optional element in the SOAP message contains the error message
and status code information. It must appear as a child element of the Body element.
 

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud