Tuesday, September 16, 2008

Service Oriented Architecture

Introduction:
SOA (service-oriented architecture) has gained its popularity due to web services.
Before dive in depth of SOA it is essential to have knowledge about its evolution. To do this we have to look back at the challenges developers have faced over the past decades and observe the solutions that have been proposed to solve their problems.
Early programmers realized that writing software have become more and more complex. They needed a better way to reuse the codes that they were rewriting. So the concepts of modular design were introduced. With modular design principles, programmers could write subroutines and functions and reuse their code. Later it was realized that cutting and pasting modules in different application had lead to maintenance problem. Whenever a bug was found in a function, all applications wherever the function was used need to be tracked in order to fix the bug and consequently deployment nightmare began.
To avoid above problem higher level of abstraction was needed. So concept of classes and object-oriented software were introduced. Developing and maintaining software lead to software complexity. So it was thought to have something to reuse functionality not only code.
So another abstraction of layer was thought to handle above problem- Component-based software. It was good solution for reuse and maintenance, but it was not able to handle all the complexities like distributed software, application integration, varying platforms, varying protocols, various devices, and internet etc.
SOA (along with web services) answers to all the above said. SOA eliminates the headache of protocol, platform, and application integration seamlessly.

Key Components of SOA:
The terms service, message, dynamic discovery, and web services play an essential role in SOA. All the terminology will be explained in detail as we move further.

Definition:
Service Oriented Architecture (SOA) is an architectural style of building software application whose goal is to achieve Loose Coupling among interacting components (software agents) so that we can reuse application. In other words Service Oriented Architecture (SOA) is a design methodology aimed at maximizing the reuse of application-neutral services to increase IT adaptability and efficiency.
Service Oriented Architecture (SOA) is the underlying structure supporting communications between services. In this context, a service is defined as a unit of work to be performed on behalf of some computing entity, such as human user or another program. SOA defines how two computing entities, such as programs, interact in such a way as to enable one entity to perform a unit of work on behalf of another entity. Service interactions are defined using a description language. Each description is self contained and loosely coupled, so that each interaction is independent of any other interaction.

Example:
Take an example of day to day life such as Purchase made online. We look at catalog available and choose a number of items. Now what happens?
We invoke one service to specify order, which in turn communicates with an inventory service to find out whether desired items requested are available in stock or not. Now order and shipping details are submitted to another service which calculates total, and tells when items should arrive and furnishes a tracking number that, through another service.
Thus entire process, from the initial order to its delivery, is managed by communication between the Web services - programs talking to other programs. All these are made possible by underlying framework that SOA provides.


Service:
A service is a unit of work done by service provider to achieve desired end results for a service consumer. Both provider and consumer roles are played by software agents on behalf of their owners.
Services are business logic that are protocol- independent, location-agnostic and contain no user state. Services are coarse-grained, meaning the service can perform its logic and return the result in a single call. Services don’t contain presentation logic, so they can be reused across diverse application.
So, a service in SOA is an exposed piece of functionality with three properties:
1. The interface contract to the service is platform independent.
2. The service can be dynamically located and invoked.
3. The service is self-contained. That is, the service maintains its own state.
- A platform-independent interface contract implies that a client from anywhere, on any OS, and in any language, can consume the service.
- Dynamic discovery hints that a discovery service (e.g., a directory service) is available. The directory service enables a look-up mechanism where consumers can go to find a service based on some criteria.
For example.
If I was looking for a credit-card authorization service, I might query the directory service to find a list of service providers that could authorize a credit card for a fee. Based on the fee, I would select a service .

Loose Coupling: Loose coupling can be defined as the state in which the impact of change (change in consumers, providers, or cross-cutting policies) is minimized across dependencies.
It refers to reduced interdependencies between modules or components, and consequently reduced interoperability risk.


Message:
Service providers and consumers communicate via messages. Services expose an interface contract. This contract defines the behavior of the service and the messages they accept and return. Because the interface contract is platform and language-independent, the technology used to define messages must also be agnostic to any specific platform/language. Therefore, messages are typically constructed using XML documents that conform to XML schema. XML provides all of the functionality, granularity, and scalability required by messages. XML provides effective communication between consumers and providers by providing a non-restrictive type of system to clearly define messages.

Dynamic discovery:
Dynamic discovery is an important piece of SOA. At high level, SOA is composed of three core pieces: service providers, service consumers, and the directory service. The role of providers and consumers are apparent but directory service needs explanation.
The directory service is an intermediary between providers and consumers. Providers register with the directory service and consumers query service directory to find service providers. Embedding directory service within SOA accomplishes the following:
- Scalability of services; we can add services incrementally.
- Decouples consumers from providers.
- Allows for hot updates of services.
- Provides a look-up service for consumers.

Web Services:
Web services play a major role in a SOA. This is because web services are built on top of well known and platform-independent protocols: HTTP, XML, UDDI, WSDL, and SOAP. These protocols fulfill the key requirements of SOA.
That is, a SOA requires that a service be dynamically discoverable and invokeable, this requirement is fulfilled by UDDI, WSDL, and SOAP.
SOA requires that service have platform-independent interface contract, this requirement is fulfilled by XML.
SOA stresses interoperability; this requirement is fulfilled by HTTP. This is why web services lie at the heart of SOA.

WSDL:
Web Services Description Language, used to describe exactly (in XML) what web services does.
UDDI:
Universal Description, Discovery, and Integration protocol, used to publish web services description.
SOAP: Simple Object Access protocol, to send xml messages using HTTP (which runs on top of TCP protocol usually on port 80)

No comments: