Probably you might have come across this term so often. I wanted to share my thoughts on defining services. Before we go any further lets take one definition from the net to continue with. So here is a great definition I picked up from the list of results that I got by typing “define: service” in Google.
A service is a self contained business function in which consumers interact through a well defined interface (contract). In this model, the consumer does not know (or care) “how” the service implements the requested business action - only that the service performs “what” is defined by its published interface (contract).
There are two key terms that we need to understand here.
- Self Contained - A self contained function is said to perform only the business function for which it was written for. If the self contained function expects an input, that is all it expects, it performs the function and returns back the result. It does not care what the consumer is going to do with the result.
- Contract - A contract is an agreement to use the service and abide by it in order to consume it. For example if the service expects an input that is mandatory for it to perform the function, and if the input is not provided then the contract is violated and the service does not work.
We can also see the word interface in that definition. An interface we can say is a bridge between a source and a destination. The consumer as per the above definition may not care how the service was implemented but has to care where it was implemented and how to reach it.
A web service is a service that sits on the web or the internet. In this case it is quite difficult to understand where the service sits and how to access it unless and otherwise the contract gives that information. Even if the consumer is able to get the contract but cannot interpret it then it is not possible for the consumer to interact with the service. So there should be a mechanism where in the consumer and the service can interact in a language that is common. Since there could be multiple consumers this language should be a global language. Welcome XML! We know that XML is technology agnostic, platform agnostic and is a best form of representing information in a structured fashion. So if the contract is in XML, and the service can be contacted through XML and the response is also in XML, then we have a service that does not care who, where and how a consumer works and the consumer does not care how the service is implemented.
Behold, the key definition of a service is still valid - “A service is a self contained business function”. To continue learning more on web services here is an article on “Introduction to web services“.
Read other Foundation Stones.