HOME | J2ME | Struts | AJAX | SOAP | SOA MEDIA STREAMING AXIS |
SOAP Tutorial
Introduction
Building Blocks
Fault Element
SOAP Header
SOAP Attachments

 

 

Basic building blocks of SOAP

Back | Tutorial Home | Next

SOAP is an XML based message called SOAP envelope and has following essential elements

  • Envelop name space - This name space does not directly point to a dtd file but to a URL alias like http://www.w3.org/2003/05/soap-envelope
  • Envelop encoding type – this element specifies the SOAP encoding rules to be followed. This name space does not directly point to a dtd file but to a URL alias like http://schemas.xmlsoap.org/soap/encoding/
  • Envelope name – Name of the SOAP message
  • Header – Meta information of the Envelop, This element is optional
  • Body – Application data container, This element is required

Lets look at the XML below

<soap:Envelope
xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
soap:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" >
<soap:Header>
<!—This is an optional block, header content here -->
</soap:Header>
<soap:Body>
<!—This is a required block, request or response data comes here-->
</soap:Body>
</soap:Envelope>

Let us look at a simple SOAP request-response login authentication routine. There is no Header element, remember!! Its optional

Request Envelope

<soap:Envelope
xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
soap:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" >
<soap:Body>
<lg:LoginRequest xmlns:lg="urn:MyServer">
<username>tom</username>
<password>tom123</password>
</lg:LoginResponse>
</soap:Body>
</soap:Envelope>

Let’s look into Body tag in more detail.

lg:Login is the method we are invoking on a service hosted at urn “MyServer”. The service "urn:MyServer" can host a lot of other methods also. Example a movie information service can host other methods like lg:MovieList, lg:TheatreList etc

<lg:MovieList xmlns:lg="urn:MyServer">
<lg:Theatre xmlns:lg="urn:MyServer">

Response Envelope

<soap:Envelope
xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
soap:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" >
<soap:Body>
<lg:LoginResponse xmlns:lg="urn:MyServer">
<Response>Congratulations !! Login Successful</Response>
</lg:LoginResponse>
</soap:Body>
</soap:Envelope>

For unsuccessful login the response element can change to

<Response>Login failed!! Wrong User Name Entered</Response>

Back | Tutorial Home | Next

site comments powered by Disqus
Download our free toolbar

toolbar powered by Conduit

| Copyright © 2009. All rights reserved | Terms and Conditions | About | Contact | Feed Back |