Web service is nothing but a simple logic that is written in any language. It is used to expose a particular server functionality to outside world so that heterogeneous application can consume it.
These web services are language independent and platform independent. Web services are mainly used for cross communication between heterogeneous technologies.
I can say that it acts as a mediator between the clients and server.
For web service or server logic we can use any language (For example, java, Dot net, PHP, etc). The main things about web service is they expose the data in JSON or XML format.
Heterogeneous application or the application developed using different platform cannot communicate with each other because they did not know the language of each other. This is similar to people who knows his local language can communicate with it only locality, he can’t communicate with other state local people.
In this case the technology like XML and JSON emerge in the internet market. These two technology or language are independent of any technology or language they can communicate with different heterogeneous application. This is similar to HINDI or ENGLISH language. If you know English language especially then you can communicate to every locality person.
Here I have shown the clear picture about the web services.
If we go inside these things I can show clear picture here.
Here I have clearly explained the Web service or server logic can be done by any language because there output will be on either JSON or XML.
This data exposed by web service by JSON or XML can be consumed by different technologies to communicate with database.
During communication between web service and different consumers the message is transported through SOAP (SIMPLE OBJECT ACCESS PROTOCOL).
Soap is a communicating protocol.
A client request to the web service for any data using SOAP message. The web service execute the logic fetching the data from the server, the retrieved data or the client requested data is now bundled into a soap message and sent to the client over the internet.
- Soap Message will contain envelop.
- Soap Envelop will contain the following things.
SOAP HEADER- It will contain address of destination.
SOAP BODY- It will contain actually message or methods that will be called.
SOAP FAULT- It will contain error info.
- The soap message will look like this.
- Now the second and most important term that is used most of the time is WSDL (Web Service Description Language).
- It contains the overall information about the web service.
- It contains information such as-
- Methods exposed in webservice.
- Return type of methods.
- Parameters of method etc.
WSDL is XML based language to provide description of webservice.
WSDL element will contain the following things.
The above figure of WSDL is not complete. I have just shown a part (half) of WSDL document to ensure that the WSDL looks like this.