SOA Patterns > REST-inspired Patterns > Content Negotiation
Content Negotiation (Balasubramanian, Booth, Erl, Riley)
How can a service capability accommodate service consumers with different media type requirements?
Different service consumers may have differing requirements for how data provided by a given service capability needs to be formatted or represented.
Allow the service capability to support alternative formats and representations by providing a means by which consumer and service can “negotiate” data characteristics at runtime.
The pattern is most commonly applied via HTTP media types that can define the format and/or representation of message data. The media type of the data is decoupled from the data itself, allowing the service to support a range of media types.
The consumer provides metadata in each request message to identify preferred and supported media types. The service attempts to accommodate preferences, but can also return the data in other supported media types when issuing the response message.
Fewer service capabilities are needed to accommodate variation in service consumer requirements. Services are able to support old and new service consumer versions concurrently using the same service capabilities.
The complexity of cache implementations is increased, and requires that caching metadata indicate what metadata input to each request may affect which representation will be returned.
Requesting metadata that is not abstract enough can introduce consumer to service implementation coupling.