Web service is a software function provided over the internet. What a normal software function does? Takes an input, processes, and gives an output. Web service also does the same over the web or internet. This is a self-contained, self-describing application. It does not depend on any programming language or operating system. Web services are hosted on the internet and can be accessed by any other system.
Let us have some thoughts on web services as a layman does.
If I build a web service, what is the method of communication?
What protocols should it use?
Can it just read? or read and write both or can it even execute some program?
Below is an example of web service,
<?xml version="1.0" encoding="utf-8"?>
From the above sample web service we can understand that from any system if the web service is called with the necessary parameters the intended function will be done. Plain English meaning of "Service" is "Work done by one person or group that benefits another". Web service is the one which is a self-contained, self-describing component of a software system which is available over the network. An application built to communicate with multiple applications need to use standard protocols for communication. XML is the standard way of communicating across different operating systems / environments.
Think of an application which you want to build and make sure that can be integrated with any other system. For this kind of requirement architecture design pattern can be "Service Oriented Architecture". This architecture exposes all the application functionalities as services. Thereby other systems can easily interact.
Web services use XML and JSon request and responses and Http protocol. Very basic elements of a web service include,
- XML (Extensible Markup Language)
- HTTP (Hyper Text Transfer Protocol)
- UDDI (Universal Description, Discovery and Integration)
- SOAP (Simple Object Access Protocol)
- WSDL (Web Services Description Language)
- REST (Representational State Transfer)
There are two types of Web Services:
Simple Object Access Protocol (SOAP) is a protocol used for implementation of web services. SOAP message is defined by standard WSDL (Web Service Description Language). SOAP message consists of an envelope, header, body, and fault. These are the building blocks of a SOAP message. These blocks are used to identify the document as SOAP message, header information, data for the call, and about any errors that happened.
REST stands for "Representational State Transfer", which is a type of architecture design. RESTful web services are implemented using REST principles. These are lightweight in nature, stateless, and cacheable. In REST based architecture, server provides access to resources and the client will access the same. Resources can have different representations such as XML, JSon, text, etc. REST uses HTTP methods GET, POST, PUT and DELETE methods for CRUD (Create, Read, Update and Delete) operations. We will discuss more on this topic in future posts.