The earliest computers didn’t talk to one-another. They were islands of information. A lot has changed since those pioneering days. Web services are the current state-of-the-art in computer to computer communications. I present below a brief history to illustrate and help explain this transformation from isolation to connectedness.
Let’s Talk! Connecting Computers
Networking technologies were developed to enable inter-computer communications. At that point you could connect two or more computers together but it still wasn’t easy to share information. There were initially no standard ways to represent or manipulate data.
Multiple, competing efforts progressed to standardize network communications. TCP/IP emerged as the primary way to interconnect networks and enabled the Internet. SMTP saw increasing adoption as an electronic mail protocol. Things were not as simple in the world of client-server communications. DCE/RPC and CORBA competed for attention, with Microsoft settling on the former. While providing a framework for client-server computing, these are still low-level binary network protocols that are not easy to use nor are they firewall-friendly. By that I mean those protocols requires a large number of TCP ports to be open which nullifies most of the security gained from a firewall.
The next major advancement in network communications was SOAP. SOAP is not a wire-level protocol meaning that SOAP messages can be transmitted via a variety of application layer protocols including HTTP and SMTP. SOAP also standardized on XML as the data representation model. Both of these concepts were transformational in that now you could use a set of ports that are usually left open on firewalls and the data could be interpreted without an understanding of a complex binary layout. Major vendors jumped on SOAP and produced a raft of web service specifications (WS-*). Why were these called “web services?” Because they used the same underlying protocol as the World-Wide-Web: HTTP!
Except this is not a completely accurate timeline. SOAP was developed after HTTP and it turns out that HTTP itself makes a great client-server computing protocol. The HTTP protocol was developed by early Internet luminaries including Tim Berners-Lee, Paul Leach and Roy Fielding. The latter published a revolutionary dissertation in 2000 in which he did an analysis of networking architecture. Within his dissertation Dr. Fielding presented Representational State Transfer, a,k.a. REST. This is an architectural pattern for producing client server communications using the rich semantics of HTTP. However, given the large investment that had been made in the WS-* suite, it took a long time for folks to realize the inherent advantages of REST over SOAP.
RESTful Web Services
Although SOAP-based services used HTTP, they did not and cannot fully leverage all of the features of HTTP. All SOAP message exchanges use the POST HTTP verb. It doesn’t matter what you want to do, the SOAP client POSTs a request to the SOAP server. This is incredibly inefficient. The majority of network transactions are data reads (I don’t have any handy references for this but I believe it to be true). HTTP has a built-in verb for fetching data: GET. HTTP GETs are by definition stateless, idempotent and without side-effects. This enables two very powerful features: scale-out and caching. Because the requests are stateless you can use a load balancer to spread them out to a farm of servers. This also enables caching of requests on intermediate nodes of the Internet such as proxies and gateways. These combined capabilities have enabled the creation of Content Delivery Networks (CDNs).
Details of REST
REST is a resource-centric architecture which gives it the following characteristics.
- Each distinct resource is named by a unique URL path.
- e.g. https://myservice.example.com/stuff/things/mything22
- The leaf element is the resource name while the intervening path elements can be thought of as containers or collections; thus the leaf element name need only be unique within the specific path hierarchy.
- CRUD (create, read, update, delete) operations map directly to the HTTP verbs PUT, GET, POST, and DELETE respectively.
- Stateless – as noted above this enabled Internet-scale services
- Standard MIME media-types for payload encoding (JSON, XML, etc.)
- Searching for resources is rooted in a container path and employs URL parameters to describe the search query
- e.g. https://myservice.example.com/stuff/things?$filter=thingnum lt 22
While all of this is cool, REST isn’t an actual protocol. Rather, it is a set of architectural styles or conventions. Several competing implementation protocols have evolved as a result. The two dominant REST API description languages are OData and OpenAPI (was: Swagger). The former is being pushed heavily by Microsoft which may explain why some in the open source community prefer the latter (and I’m sure there are lots of other good reasons). In any case they both aspire to the same goals: providing a standard way for a service to describe its capabilities (the service description endpoint) and the schema of its data (the service metadata endpoint).
Examples of RESTful Web Services
Where to start? They are all around us. Facebook, Amazon, Google, Microsoft all expose resources via web services. I have code that calls the Amazon AWS Simple Queue Service for event message delivery. I am developing code to call the Microsoft Azure Active Directory Graph API (AAD Graph for short).
My employer, the University of Washington, hosts a number of RESTful web services. One that has been in use for a while is the Groups Web Service. A new middleware service is being developed to provide a standardized way to access University data. This is known as the Enterprise Integration Platform.
My next post will dive into making web service calls using the PowerShell scripting language.
Example PowerShell and a PowerPoint deck at https://github.com/erickool/ws-powershell