Analysis and Service Modeling with REST
- 9.1. Uniform Contract Modeling and REST Service Inventory Modeling
- 9.2. REST Service Modeling
9.1 Uniform Contract Modeling and REST Service Inventory Modeling
9.2 REST Service Modeling
A fundamental characteristic of SOA projects is that they emphasize the need for working toward a strategic target state that the delivery of each service is intended to support. In order to realize this, some level of increased up-front analysis effort is generally necessary. Therefore, a primary way in which SOA project delivery methodologies differ is in how they position and prioritize analysis-related phases. This consideration is equally relevant to any service implementation medium. In fact, the actual medium and associated technology that will be used to physically design and develop services may not actually be known during initial analysis stages. It may be better to determine whether REST or another medium is the most suitable choice after having had the opportunity to model a number of planned service candidates and study their anticipated composition and interaction requirements.
There are two primary analysis phases in a typical SOA project:
- the analysis of individual services in relation to business process automation
- the collective analysis of a service inventory
The service-oriented analysis phase is dedicated to producing conceptual service definitions (service candidates) as part of the functional decomposition of business process logic. The service inventory analysis establishes a cycle whereby the service-oriented analysis process is carried out iteratively to whatever extent the project methodology will allow.
9.1. Uniform Contract Modeling and REST Service Inventory Modeling
As explained in Chapter 4, a service inventory is a collection of services that are independently owned, governed, and standardized. When we apply the Uniform Contract {400} constraint during an SOA project, we typically do so for a specific service inventory. This is because a uniform contract will end up standardizing a number of aspects pertaining to service capability representation, data representation, message exchange, and message processing. The definition of a uniform contract is ideally performed in advance of individual REST service contract design because each REST service contract will be required to form dependencies on and operate within the scope of the features offered by its associated uniform contract.
Organizations that apply Enterprise Inventory [461] to build a single inventory of REST services will typically rely on a single over-arching uniform contract to establish baseline communication standards. Those that proceed with the Domain Inventory [458] approach instead will most likely need to define a separate uniform contract for each domain service inventory. Because domain service inventories tend to vary in terms of standardization and governance, separate uniform contracts can be created to accommodate these individual requirements. This is why uniform contract modeling can be part of the service inventory analysis project stage.
In the Service Inventory Analysis section from Chapter 8, we explained that the purpose of this stage is to enable a project team to first define the scope of a service inventory via the authoring of a service inventory blueprint. This specification is populated by the repeated execution of the service inventory analysis cycle. Once all (or as many iterations as are allowed) are completed, we have a set of service candidates that have been (hopefully) well-defined, individually and in relation to each other. The next step after that is to proceed with the design of the respective service contracts.
When we know in advance that we will be delivering these services using REST, it is beneficial to incorporate the modeling of the inventory’s uniform contract during the modeling of the service inventory itself. This is because as we perform each service-oriented analysis process and as we model and refine each service candidate and each service capability candidate, we gather more and more intelligence about the business automation requirements that are distinct to that service inventory. Some of this information will be relevant to how we define the methods and media types of the uniform contract.
For example:
- understanding the types of information and documents that will need to be exchanged and processed can help define necessary media types
- understanding the service models (entity, utility, task, etc.) in use by service candidates can help determine which available methods should be supported
- understanding policies and rules that are required to regulate certain types of interaction can help determine when certain methods should not be used, or help define special features that may be required by some methods
- understanding how service capability candidates may need to be composed can help determine suitable methods
- understanding certain quality-of-service requirements (especially in relation to reliability, security, transactions, etc.) can help determine the need to support special features of methods, and may further help identify the need to issue a set of pre-defined messages that can be standardized as complex methods (as explained in Chapter 10)
A practical means of incorporating the task of uniform contract modeling as part of the service inventory analysis is to group it with the Define Technology Architecture step (Figure 9.1). It is during this step that general service inventory architecture characteristics and requirements are identified from the same types of intelligence we collect for the definition of uniform contract features. In this context, the uniform contract is essentially being defined as an extension to the standardized technology architecture for the service inventory.
Figure 9.1. The service inventory analysis cycle diagram from Chapter 8 augmented to include uniform contract modeling as an iterative task.
If combining the Model Uniform Contract task with the Define Technology Architecture step turns out to be an unsuitable grouping, then the Model Uniform Contract task can be positioned as its own step within the cycle.
When we begin working on the uniform contract definition, one of the key decisions will be to determine the sources to be used to populate its methods and media types. As a general starting point, we can look to the HTTP specification for an initial set of methods, and the IANA Media Type Registry for the initial media types. Further media types and possibly further methods may come from a variety of internal and external sources.
Before continuing, have a quick look at Figure 9.4 in the upcoming REST Service Modeling Process section. Note how the symbols for Steps 6 and 11 contain an asterisk in the top right corner. As explained in this section, this indicates that during this step we are modeling REST service candidates that either:
- incorporate methods and/or media types already modeled for the uniform contract, or...
- introduce the need to add or augment methods and/or media types for the uniform contract.
This type of two-way relationship between the Perform Service-Oriented Analysis step (which encompasses the REST service modeling process) and the Model Uniform Contract task is a natural dynamic of the service inventory analysis cycle.
REST Constraints and Uniform Contract Modeling
Although REST constraints are primarily applied during the physical design of service architectures, it can be helpful to take them into consideration as the uniform contract takes shape during the service-oriented analysis stage.
For example:
- Stateless {395} – From the data exchange requirements we are able to model between service candidates, can we determine whether services will be able to remain stateless between requests?
- Cache {398} – Are we able to identify any request messages with responses that can be cached and returned for subsequent requests instead of needing to be processed redundantly?
- Uniform Contract {400} – Can all methods and media types we are associating with the uniform contract during this stage be genuinely reused by service candidates?
- Layered System {404} – Do we know enough about the underlying technology architecture to determine whether services and their consumers can tell the difference between communicating directly or communicating via intermediary middleware?
The extent to which concrete aspects of REST constraint application can be factored into how we model the uniform contract will depend directly on:
- the extent to which the service inventory technology architecture is defined during iterations of the service inventory analysis cycle, and...
- the extent to which we learn about a given business process’s underlying automation requirements during Step 2 of the service-oriented analysis process (as explained in Chapter 8).
Much of this will be dependent on the amount of information we have and are able to gather about the underlying infrastructure and overall ecosystem in which the inventory of services will reside. For example, if we know in advance that we are delivering a set of services within an environment riddled with existing legacy systems and middleware, we will be able to gain access to many information sources that will help determine boundaries, limitations, and options when it comes to service and uniform contract definition. On the other hand, if we are planning to build a brand new environment for our service inventory, there will usually be many more options for creating and tuning the technology architecture in support of how the services (and the uniform contract) can best fulfill business automation requirements.
REST Service Centralization and Normalization
Logic Centralization [475] attempts to avoid many of the pitfalls associated with redundant logic implemented across services by centralizing the logic in the form of a single normalized service. Redundant logic can lead to increased maintenance overhead both on an on-going basis and when business requirements change. It can further lead to governance and configuration management issues, especially in cases where the redundant logic is owned by different groups within an organization.
Because, within REST service implementations, the service contract is not “packaged” with the service architecture and logic, it is relatively easy for others in an IT department to add new REST services to a service inventory, particularly in the absence of a contract-first design approach. This tends to result in service capabilities that perform functions redundant with those provided by existing REST services. For example, a new REST service may inadvertently add an entity-centric service capability that belongs to the functional context of an existing REST entity service.
This issue can be addressed by applying Service Normalization [506], a pattern related to Logic Centralization [475], but one that views the design of services from a service inventory perspective. A normalized service inventory is designed with a clear blueprint and careful attention to service boundaries. These boundaries are defined on a functional basis. New logic that needs to be incorporated into a service inventory is first analyzed for its coherency in relation to the functional boundaries of existing services (Figure 9.2).
Figure 9.2. A service inventory comprised of REST services, each with a distinct functional boundary. When no one boundary overlaps the other, Service Normalization [506] has been applied to its full extent.
Normalizing a REST-centric service inventory requires up-front analysis, established governance practices, and a “whole-of-inventory” perspective to be applied. Normalization makes it easier for service consumers to find and correctly use the functionality they need in a consistent, logically partitioned space of REST service capabilities grouped into distinct functional contexts.