What are web services and what are they used for?
Web services are functions you call over the network from another program, not from a human — software talking to software.
A web service exposes an operation that a remote program can invoke, much like calling a function, except the call travels over the network (usually HTTP). The classic scenario: an airline's flight system detects a delay and needs to text affected passengers, so its server calls a separate SMS service to send each message automatically — no employee in the loop.
Defining characteristics:
- Machine-to-machine — built for programs, not human users browsing.
- Black-box principle — the caller uses the service without seeing how it is implemented inside.
- Loose coupling — client and provider are independent and can change separately.
- Open standards — typically HTTP-based (REST, SOAP) so anyone can interoperate.
- Publishable as a public API — e.g. the Google APIs.
A service is described by one or more operations. An operation has a name, parameters, and a result type, written like a function signature:
sendSMS(phoneNumber, message): Boolean
This says: call sendSMS with a phone number and a message text, and you get back a Boolean telling you whether it worked.
Memory tip: a website is for people, a web service is for programs.