Types of Web Services
Web services describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available. Used primarily as a means for businesses to communicate with each other and with clients, Web services allow organizations to communicate data without intimate knowledge of each other's IT systems behind the firewall.
There are mainly two types of web services.
- SOAP (Simple Object Access Protocol)
- REST (REpresentational State Transfer)
SOAP (Simple Object Access Protocol)
SOAP stands for Simple Object Access Protocol, it is a xml based protocol that enables the applications to communicate over HTTP. SOAP is a w3c standard, platform and language independent format for sending and receiving messages. The SOAP envelope contains two parts:
- An optional header providing information on authentication, encoding of data, or how a recipient of a SOAP message should process the message.
- The body that contains the message. These messages can be defined using the WSDL specification.
SOAP defines the XML-based message format that Web service-enabled applications use to communicate and inter-operate with each other over the Web. The heterogeneous environment of the Web demands that applications support a common data encoding protocol and message format. SOAP is a standard for encoding messages in XML that invoke functions in other applications. SOAP commonly uses HTTP, but other protocols such as Simple Mail Transfer Protocol (SMTP) may by used. SOAP can be used to exchange complete documents or to call a remote procedure.
Advantages of SOAP
- It is platform and language independent.
- SOAP provides simplified communications through proxies and firewalls, as mentioned above.
- It has the ability to leverage different transport protocols, including HTTP and SMTP, as well as others.
DisAdvantages of SOAP
- SOAP is typically much slower than other types of middleware standards, including CORBA. This due to the fact that SOAP uses a verbose XML format. You need to fully understand the performance limitations before building applications around SOAP.
- SOAP is typically limited to pooling, and not event notifications, when leveraging HTTP for transport. What's more, only one client can use the services of one server in typical situations.
- SOAP has different levels of support, depending upon the programming language supported. For example, SOAP support within Python and PHP is not as strong as it is within Java and .NET.
REST (REpresentational State Transfer)
REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications, it is primarily used to build Web services that are lightweight, maintainable, and scalable. A service based on REST is called a RESTful service. REST is not dependent on any protocol, but almost every RESTful service uses HTTP as its underlying protocol. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client/server architecture and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.
Features of a RESTful Services
RESTful services should have following properties and features:
- Uniform interface
- Links between resources
Difference between SOAP and RESTful Services
There are many differences between SOAP and REST web services. The important differences between SOAP and REST are given below:
Which is more favourable?
REST was designed to be a more straightforward and easy to implement alternative to heavyweight SOAP for web service access. SOAP functions
well in distributed environments where REST assumes a direct point to point communication. Also, SOAP allows for services to describe themselves
to clients and in some languages allows for automation. On the other hand, REST is fast as less processing is required, uses less bandwidth and
is closer to technologies used in web design.
The choice on which to use is totally dependent on what the requirement. For example, SOAP is a better choice for applications that have complex API so as to describe the services and methods, where formal contracts are agreed for the exchange format, where a guaranteed level of security is required etc. REST will be preferred when limiting bandwidth and resources, when operations are can be stateless and the information can be cached.