SOA Tips-Expose Coarse-Grained Service Interfaces to external Clients
24 Apr 2007SOA-Tips
Expose Coarse-Grained Service Interfaces to external Clients. Instead of exposing multiple interfaces that effect small state changes in a system, expose fewer service interfaces that can affect complete state changes in the system. This will reduce the volume of data exchanges between a service and its external clients and will significantly reduce the cost of processing the data and improve the latency of network resources in the process. Always hide the details of the applications the service needs to interact with to get a job done by hiding them behind endpoints that expose coarse-grained interfaces. This will allow you to exchange richer business documents between a service and its external clients.
Exposing service interfaces that are fine-grained could kill system performance. You can get into this situation if you blindly go about exposing your existing EJBs or legacy applications as web-services; something that can unintentionally creep in when you do Implementation-First or Code-First development. Your objective is not to expose getters and setters. Remember that unlike Object-Oriented programming where you are exposing objects, in SOA you are exposing services.
Here are some strategies that you could adopt:
The service that you expose to external clients could perform aggregation on demand and retrieve the data from disparate systems. The Service Interface exposed to the client, when invoked, could aggregate this data from multiple different services and return a consolidated business document to its external clients.
Or better still, the service that you expose to external clients could also perform aggregation by replication. The aggregating service could contact other services during off-peak hours and replicate the data locally if it is possible. Then when external clients invoke the service it could return the aggregated data as a rich business document in real-time.