Web Service is used to transfer data using communication protocols. Communication protocols, it realizes applications with a "own language” That independs of the programming language, operating system, hardware, and allow you to modify and add functionality and reuse existing systems, improving and integrating information.
The web service process is characterized by being triggered by a requesting system that transmits data through communication protocols and is sent to the web service, where the database is consulted and the the information obtained is stored and returned to the requesting server.
The protocols are tools that help in the communication between the web services.
Web services are standardized protocols. There are SOAP (Simple Object Access Protocol) and REST (Representational State Transfer).
SOAP only uses the XML language, both for sending and server receipts. The sending for server communication is through the HTTP post verb.
REST is an architectural style, it is more flexible and can be used for HTTP standard verbs such as post, get, put, patch, delete, etc. The language can be used with JSON, XML among others.
The most used communication protocol today is REST.
The main motivations for the use of web services are the standardization and integration among services, code reuse because it is used in several platforms and because it´s more secure,as the web service prevents a direct access to the access to the database.