Requirements for a piece of software to be identified as web service are (by W3C definition):
- it should be designed for machine-to-machine (or application-to-application) interaction
- it should be interoperable and platform-independent
- it should allow communication over a network
This machine-to-machine communication is based on the client-server approach where main concepts are requests (service inputs) and responses (service outputs). If application A (service consumer) needs to do some work with application B (service provider), it will send a request containing data for specific operation - it could be getting data or changing the state of some object in a database of application B. Application B will process the request from application A and then send a response to it.
Since communication should take place over a network, how does application A knows endpoint, the structure of request it should provide to application B or structure of response it will receive? It's solved by concept of service definition - application B should expose it so that service caller, in this case, application A knows how to communicate with it. So, a service definition is considered a contract between the service provider and service consumer and it contains the following elements:
- request and response format - message exchange format (for example XML, JSON)
- request structure
- response structure
- endpoint - location of service
Data transport between service consumer and service provider could be done using different ways of transport - for example directly over HTTP or indirectly using MQ.
There are mainly two types of web services:
They are briefly discussed in this article.