It may come as a surprise to our long-term readers that even after seven years of talking about Web services and service-oriented architecture (SOA), ZapThink still has something novel and interesting to say about what a service truly is. But in fact, although we define the term repeatedly for business, technical, and mixed audiences, there are still some subtleties to the definition that underscore the fundamental nature of the service abstraction, and they also underscore the connection between that abstraction and some of the infrastructure choices service-oriented architects must make. So, without fear of tripping up on the oxymoron of a concrete abstraction, let's delve into what ZapThink really means by a service.
Implementations, interfaces, and abstractions
As we discussed in our Subtleties of Service Convergence ZapFlash, the term "Service" is overloaded even within the IT context. But while that ZapFlash differentiated between the services we speak about in the context of SOA from other IT services, this ZapFlash focuses only on the subtleties of the definition within the SOA context entirely. Even within this relatively narrow context, however, people still often get confused about the level of abstraction of a service. Basically, there are three levels of abstraction we work on in the context of SOA:
1. Service implementation -- at this level of abstraction we're talking about software. A service implementation is made up of running code. This is where the Service Component Architecture (SCA) lives, as it deals with service components, which are implementations can consume or provide services (in the sense of #2 below).
2. Service interface -- Web services live at this level, as a Web Services Description Language (WSDL) file provides a contract for the interface, but says nothing about the underlying implementation. Web services, however, are not the only kind of service interface, because service contracts are not always WSDL files. Sometimes service interfaces are loosely coupled, but many times they're not.
3. Abstracted service -- A representation of a business capability or data that the organization can compose with other such services to implement business processes. An abstracted service is typically a business service, but not necessarily, as there is a role for abstracted IT services as well. However, all business services should be abstracted services. Such business services are the sorts of services ZapThink focuses on, as they are the core abstraction that underlies SOA. Abstracted services should always be loosely coupled, although the specific coupling requirements can vary. Building loosely coupled abstracted services thus becomes the core technical challenge of implementing SOA.
So far so good -- but the real question here is how we make an abstracted service actually work, when the tools at our disposal are the service implementations and interfaces and all the infrastructure that goes along with them. It's one thing to talk about "representations of business capabilities," and quite another to string your ones and zeroes together into something that actually runs.
Service contracts, SOA infrastructure, and loose coupling
The first critical point to understanding abstracted services is to understand that there is typically a many-to-many relationship between services and service contracts, as ZapThink explained in our Understanding the Relationships among Services, Contracts, and Policies ZapFlash. Clearly, a service implementation may support multiple contracts, each of which could correspond to a particular service interface, for, say, a particular type of consumer. Similarly, there might be several implementations that support a single contract, and hence a single service interface, for the purposes of scalability or fault tolerance, for instance.
With abstracted services, however, the relationship becomes what we might call "many-to-many-to-many": a particular abstracted service might have several contracts that represent relationships with various consumers, while also representing multiple service interfaces that themselves might each have one or more service implementations. This approach might sound overly complex, but it's the key to loosely coupling the abstracted service. To illustrate this point, let's work though an example.
Let's say we have a Customer Information service that different lines of business in a large enterprise can consume and compose to provide or update any information about their customers that the lines of business might need. From the business perspective, this is a single business service that any line of business can use as per the policies set out for that service. From the IT perspective, however, it makes sense to implement the Customer Information service as a set of service interfaces with different service contracts in order to support the somewhat different needs for customer information that the various lines of business might have. Furthermore, each service interface may represent several service implementations that the SOA management infrastructure can leverage as necessary to meet the service levels set out in the contracts for both the abstracted Service as well as the service interfaces, in addition to the policies that may apply to these services as well as other services in production.
In this example, the complexity beneath the service abstraction is necessary to support the loose coupling of the abstracted service. For example, the line of business consumers may need different formats for the customer information, or may require different data as part of the response from the service. To loosely couple such consumers, an intermediary (or set of intermediaries) may perform a transformation that can take the output from any of the service interfaces and put it into the format the particular consumer requires, as per the contract in place that governs the relationship between that particular consumer and the abstracted service. Then, either the management infrastructure (or possibly the integration infrastructure) may offer content-based routing of the requests from particular service interfaces to the underlying implementations, based upon runtime policies in effect at the time.
Furthermore, a service interface may support several contracts, for example, when one service interface has multiple bindings. In the case of a Web service, each WSDL file specifies a binding, so to support more than one, there should be multiple service contracts for the service interface. Each binding may then correspond to its own service implementation, or in the more general case, multiple implementations may support each binding, or one implementation may support multiple bindings.
In any case, loose coupling means more than being able to support different consumers with different needs. It also means building for change. Because we have a governance and management infrastructure in place that enables this many-to-many-to-many relationship among abstracted services, service interfaces, and service implementations, we are able to respond to those changes in a loosely coupled manner as requirements evolve -- in other words, without breaking anything.
For example, if one consumer changed its required data format, we could introduce a new contract which might require a new transformation on the intermediary between the service interface and the abstracted service, but wouldn't impact the service interface directly or any of the service implementations. Another example might be the need to upgrade or add a new data source to support the service. Such a change might require a new implementation of one or more service interfaces. But if the contracts for those interfaces don't change, then the abstracted service is unaffected, and neither are the consumers. A third example would be a policy update that would change the content-based routing behavior between the service interfaces and their implementations. In fact, we see this application of content-based routing as more of a management challenge than an integration task because of this need to support runtime policy changes.
The ZapThink take
There's an interesting side-effect of taking this Service-oriented approach to implementing abstracted services: it becomes difficult to count how many services you have. Sure, in this example, you have one Customer Information Service from the business perspective, but it actually might have several service contracts, each of which have several interfaces -- and those interfaces may change in number over time. How you count your services may impact your SOA maturity model, for example, or even your software licensing costs, so this question may be more important than it seems.
But in the final analysis, the most important thing to remember is that the Customer Information abstracted service is but a single example. In the general case, the architect must select from a variety of SOA infrastructure patterns depending on the specifics of the problem at hand, as we explained in our recent SOA Infrastructure Patterns and the Intermediary Approach ZapFlash. The bottom line is that loose coupling presents architectural challenges that are at the heart of planning and implementing the SOA infrastructure. Building the Service abstraction presents a simplified representation to the business but requires additional efforts under the covers to make that abstraction a concrete reality. This is the work of SOA: implementing and maintaining loosely coupled business Services that are at the core of any successful SOA implementation.