I constantly stumble upon discussions about SOA vs API, about what’s the “better” model or which one will replace the other. I want to summarise my thoughts in this post.
There are many definitions of APIs out there. At its most basic form an API “specifies how software components should interact with each other” (see Wikipedia). In the API Strategy Guide, the authors define an “API is a way for two computer applications to talk to each other over a network (predominantly the Internet) using a common language that they both understand.”
A more recent and very appropriate definition is given in 3scale’s ebook Winning in the API Economy where the authors refer to a Web API as (I prefer the term Network API as it does not necessarily need to use Web technologies):
An interface to a software component that can be invoked at a distance over a communications network using standards based technologies.
Find some more thoughts on APIs in my post about the purpose of an API strategy.
There are also plenty of definitions for service-oriented architectures (SOA). The one I prefer is from the OpenGroup, which says that:
SOA is an architectural style that supports service-orientation.
Service-orientation is a way of thinking in terms of services and service-based development and the outcomes of services.
A service is a logical representation of a repeatable business activity that has a specified outcome (e.g., check customer credit, provide weather data, consolidate drilling reports), is self-contained, may be composed of other services, and is a “black box” to consumers of the service.
Essentially, SOA achieves a breakout from thinking in applications but thinking in more fine-grained functions (i.e., services), where applications can be composed of various such services. This has some inherent benefits such as higher flexibility, agility, re-usability and simpler integration. In fact, ServiceOrientation.com lists a whole range of additional benefits such as loose coupling, abstraction, autonomy, statelessness, discoverability, composability, or interoperability.
You can download the following poster which gives a lot of details regarding these benefits.
(Source: http://serviceorientation.com/)
The core building blocks of a SOA are very similar and recurring:
A service provider holds a service implementation but only describes the interface to it and how to use it via the service description. The provider would use a discovery mechanism to find a service directory and register the service description there.
A service consumer would also use a discover mechanism to find a service directory and then the relevant service in there, which based on the description fits the requirements of the consumer. Using this description enables the consumer to invoke the service directly from the service provider.
This is the theory and it sounds good. The reality is often a bit less simple. I have practical experience specifically with Jini, which is (a quite old) SOA originally designed and implemented by Sun Microsystems. Now it goes under the name of River under the Apache umbrella. It is outdated and probably not used much nowadays. Probably a more current SOA is SORCER with which I have no experience. Using Jini I implemented an Open Management System, which combined different types of multimedia content from different sources and allowed to playback the content based on the capabilities of distributed and mobile devices. That worked alright. It was a prototype. I am sure I would have run into scalability and inconsistency problems fairly soon. The service directory is clearly a single-point-of-failure as well as a bottleneck and if you have several you will run into all classic network problems (such as the CAP theorem).
Jini abstracts an additional level over remote method invocation (RMI) which can be quite heavyweight, not really straightforward to implement and you need proprietary libraries for all supported devices or operating systems.
SOA is often used in combination with enterprise service bus (ESB), which should help to publish, use and orchestrate services within a company. This can eventually also get out of hand as depicted in the figure below.
(Source: Agigee's APIs inside the Enterprise)
All in all SOA (or Jini as one concrete instantiation) increases flexibility and agility but still was complex to implement and maintain.
In SOA we are using interfaces to invoke the various services. So, we could argue -- also based on the definitions given above -- that APIs inherently are a part of every service oriented architecture solution.
The notion of API changed over time from simply a technical expression to a paradigm. Today we use the term API to express opening up company assets to external developers. In essence this is still true to the original usage, namely encapsulating complex data or algorithms in a black box to which the API is the key to access.
If we look at APIs today the same six core building blocks of SOA as mentioned above exist in some shape or form. Most of these work alright, and the popularity and explosion of public API registrations (see “API adoption – we are still in the early days”) is evidence enough. However, especially two areas require substantial improvement: service directories and discovery mechanisms. There are some API directories available such as ProgrammableWeb, APIhub, or Mashape. As a developer you have to human-read them, find them, read the developer documentation, (often sign up), and then implement the APIs. An automatic or machine-based approach would be useful. Especially because this space of public APIs is getting more and more convoluted and confusing.
Two recent developments in the API Economy clearly show that this weakness has been identified and is worked on:
RAML is the RESTful API Modelling Language that facilitates reuse, API description based on patterns, and increase of discoverability.
API Commons is an initiative that aims to come up with simple and transparent mechanisms for the copyright free sharing of APIs. This should result in collaborative design of API specifications, interfaces and data models, which should allow sharing best-practices and increase re-usability.
The API / SOA duality is interesting, overlapping, and mutually supportive. I don’t think there is a SOA or API relation. I think it is more about the core building blocks of the early SOA and how the lessons learned can be transferred into modern API-based architectures.
What we currently subsume under the API Economy is an evolution of SOA including a much deeper integration between business and API strategy. With APIs the potential barrier between business and technology has been lowered even more, which facilitates this strategy integration.
API description and discovery will be the main challenges for the near future in the API Economy.
Just today I attended a Webinar by MuleSoft about SOA and Legacy Modernisation.
Apigee also held a webinar earlier about SOA and APIs. Find slides and video embedded below.
APIs Inside Enterprise - SOA Displacement? from Apigee