SOAP( Simple Object Access Protocol) As per the definition offered ...

squabbletownmushySoftware and s/w Development

Dec 14, 2013 (3 years and 8 months ago)

68 views

SOAP( Simple Object Access Protocol)


As per the definition offered by the W3C, "SOAP is a lightweight protocol for
exchange of information in a decentralized, distributed environment. It is an XML based
protocol that consists of three parts:
i. an envelope that defines a framework for describing what is in a message and how
to process it.
ii. a set of encoding rules for expressing instances of application-defined data types,
iii. a convention for representing remote procedure calls and responses.

SOAP can be potentially used in combination with a variety of other protocols.
Basically the Simple Object Access Protocol (SOAP) is a mechanism for sending
information in an extensible format. SOAP can be used to send messages as well as RPC
encoded as XML. One can compare SOAP to other wire protocols like IIOP for CORBA
& JRMP for RMI.

SOAP can potentially be used in combination with a variety of other protocols.
The combination along with http allows it to pass across corporate firewalls with ease.

Definition of Name Spaces:

An XML namespace is a collection of names identified by a URI reference [RFC
2396] which are used in XML documents as element types and attribute names. XML
name spaces have an internal structure and are not mathematically speaking a set.
Namespaces are used to uniquely identify elements and attributes using a prefix. This
prevents collisions between elements and attributes in other documents that may have the
same element or attributes. SOAP uses the SOAP-ENV and the SOAP-ENC namespaces.
It also provides a clear understanding as to which elements in the XML related
document belong to SOAP and which elements are application specific. The entire
documentation related to name spacing can be found on the w3c site for name services.
Refer to RFC2396 for more details on XML name spaces.


There are 2 namespaces for consideration here:


1. Envelope:

SOAP Envelope that has the name space identifier
"http://schemas.xmlsoap.org/soap/envelope"

2. Serialization

SOAP Serialization that has the name space identifier
"http://schemas.xmlsoap.org/soap/encoding"


As described above SOAP messages are encoded as XML Documents and these
consist of the following:

1. An Mandatory SOAP envelope
2. An optional SOAP header
3. A Mandatory SOAP Body.



Here’s a sample soap encoded request: (This is on the .NET platform)



POST /WebService2/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Multiply"

<?xml version="1.0" encoding="utf-8"?>
<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>
<Multiply xmlns="http://tempuri.org/">
<n1>int</n1>
<n2>int</n2>
</Multiply>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<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>
<MultiplyResponse xmlns="http://tempuri.org/">
<MultiplyResult>int</MultiplyResult>
</MultiplyResponse>
</soap:Body>
</soap:Envelope>
HTTP GET
The following is a sample HTTP GET request and response. The placeholders shown
need to be replaced with actual values.
GET /WebService2/Service1.asmx/Multiply?n1=string&n2=string HTTP/1.1
Host: localhost
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<int xmlns="http://tempuri.org/">int</int>
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown
need to be replaced with actual values.
POST /WebService2/Service1.asmx/Multiply HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length

n1=string&n2=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<int xmlns="http://tempuri.org/">int</int>


Advantages Of SOAP


HTTP protocol uses port 80 to communicate over the Internet. SOAP uses HTTP
as its transport mechanism. This improves cross-platform interoperability using the Web
and XML. Enables different programs, written in different languages and running on
different platforms, to communicate with each other. SOAP uses HTTP for transport
binding. Most organizations are familiar with HTTP and already have it incorporated into
their network infrastructure. Hence there are no complex changes to the network or
firewalls needed.


SOAP node

Implemented at client(sender) and server(receiver). Processes messages according
to the formal set of conventions. Enforces the rules that govern the exchange of SOAP
messages. Accesses the services provided by the underlying protocols through SOAP
bindings.

SOAP Header

This is a generic mechanism for adding features to a SOAP message in a decentralized
manner. No prior agreement between the communicating parties is required.

Header may be edited by intermediaries to change the information to be sent to
the receiver. There are two types of headers are available in HTTP

1. Request Header – for request messages

2. Response Header – for response messages




Security Constraints & how they are dealt:

There is a potential security threat due to plain text nature of data. This is because
data encoding is done in XML which is just plain text.

Security features therefore may be added to the SOAP header. Also transport
protocols such as SSL, TLS, and IP Security (IPSec) can provide the integrity and
confidentiality of the message during transmission.

What SOAP is NOT?

1. It is not simple.
2. It is not object based.
3. It is not access aware.
4. It’s not a component model (will not replace EJBs).
5. It’s not a programming language on its own.

SOAP toolkits available to create and parse the SOAP messages.


1. Microsoft SOAP Toolkit 2.0 translates COM function calls to SOAP.
2. Apache toolkit translates Java function calls to SOAP encoded calls.
3. Microsoft.NET allows you to write the functions and then creates SOAP structure
on its own
4. IBM’s development kit also currently creates the SOAP encoding.


Other Major Advantages & Observations are as follows:


 SOAP ensures Cross Platform Interoperability.

 It can and does support a range of applications – RPC, XML.

 It’s Small and easy to implement. Can reuse existing XML Parsers and HTTP
libraries.

 Firewalls block most ports, except the standard HTTP port 80. SOAP uses this
port and manages to cross firewalls.

 Most distributed object protocols like DCOM use dynamically assigned ports for
remote method invocations.

Some of the Grey Areas are as follows:


 Still Evolving as multiple companies are dealing with it simultaneously.

 SOAP data is sent as XML text for standardization.

 Converting all data into text and parsing it back into data structures at the other
end can use up quite a bit of processing power.

 No inbuilt security features.



SOAP Structure: For simple server client architecture