The details of a Service Layer are at the discretion of the implementers. However, like any architectural choices, there are better ones as well as some that are not so good. The PanDOORA architectural template recommends an approach that provides advantages over some less-structured but simpler-to-understand designs.
The thinnest possible Service Layer has only three elements:
- A back-end adaptor that knows how to send/receive messages to/from the existing system.
- A front-end Web service that is accessible by the service consumers.
- A mediation layer that converts between the two messaging and invocation styles.
In the simplest implementation all three elements could actually be coded within the “doPost” method of a single servlet. Unfortunately, doing it that way creates an undesirable coupling between the elements and guarantees that a change to any part ripples through the code.