So what is a web service? Lets try and come up with the simple and clear definition. Is it as simple as saying that its a service that is delivered over the web?
What is the W3C definition? Who or what is the W3C first of all?
The World Wide Web Consortium (W3C) is an international community where Member organizations, a full-time staff, and the public work together to develop Web standards. Led by Web inventor and Director Tim Berners-Lee and CEO Jeffrey Jaffe, W3C’s mission is to lead the Web to its full potential.
The W3C defined a web service as “a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other web-related standards”.
In practice, a web service is a service running on a server, listening for requests on a network (local or internet), and serving a response as a web document. Typically these days that response would be XML or JSON, transferred over HTTP.
Implementing An Application
Lets come up with an example. Now imagine we have a web application, that looks up a car data. This web application has a User Interface (UI), that talks to some business logic, that talks to some data logic, that grabs some data from the database, and then processes that and returns it to the UI in HTML format to display some car details.
If another team comes along and says “oh, we love your car data, can we use it as part of our application”.
Well here you have options. You can give them the logic so that they can duplicate it.
But now you have 2 different code bases talking to your database which creates many problems. For example, if you change the database, any changes you make can break their code as they wont be aware of them.
Implementing A Web Service
The other way to do this is to change your code into a web service. This way you create a well defined interface that allows the other team to grab your data/and business logic without having to duplicate what you have done already.
If we go back to our w3c definition of a web service.
- Our service is now on the network, so it isnt restricted to just use by us.
- That also makes it interoperable, as anyone can use our service no matter what platform they are on so could be browser, mobile phone, etc
- Its machine to machine (ie application to application) as the computers running our browser or phone app is talking to the server now running our web service.
So as we have seen here the essence of a web service is a create functionality that is easy to use from multiple sources, without creating dependencies on the implementation of that web service.