A web service is an application or data source that is accessible via a standard web protocol (HTTP or HTTPS). Unlike web applications, web services are designed to communicate with other programs, rather than directly with users.
While web services can provide data in a number of different formats, XML and JSON are the most common. These standard text-based formats can be easily recognized and parsed by another program that receives the data. The most common web service protocol – SOAP (Simple Object Access Protocol) – simply adds a header to each XML message before it is transferred over HTTP.
Business-oriented web services may use a standard called UDDI. This formats data in a specific type of XML known as the Web Services Description Language, or WSDL. While UDDI transmits .WSDL files instead of standard .XML files, it may still use the SOAP protocol to transfer data.
Most web services provide an API, or a set of functions and commands, that can be used to access the data. For example, Twitter provides an API that allows developers to access tweets from the service and receive the data in JSON format. Yelp provides an API for programmers to access information about businesses, which can be displayed directly in an app or website. Google Maps provides an API for receiving geographical data and directions from the Google Maps database.
NOTE: An API is a specific set of commands and guidelines used for accessing data, while a web service is an actual service provided by an Internet-based source.