What is WebService? Why it is Needed?


In General, software applications are developed to be consumed by the human beings, where a person sends a request to a software service which in-turn returns a response in human readable format.

In the modern era of technology if you want to build a software application you don't need to build each and everything from scratch. There are lots of ready made services available which you can plug into your application and you can start providing those services in your application.

For example you want to display whether forecast information you don't need to collect, process and render the data in your application. You can buy the services from the people who already well-established in processing and publishing such kind of data.

Web services allow us to do these kind of implementations.

Web Services is the mechanism or the medium of communication through which two applications / machines will exchange the data irrespective of their underline architecture and the technology.

As an example, consider the following WebService


This WebService can be called by a Software Application using SOAP or HTTP protocol.

Web Services can be implemented in different ways, but the following two are the popular implementations approaches.
SOAP (Simple Object Access Protocol)
REST (Representational State Transfer architecture)
SOAP

SOAP is a standard protocol defined by the W3C Standard for sending and receiving web service requests and responses.

SOAP uses the XML format to send and receive the request and hence the data is platform independent data. SOAP messages are exchanged between the provider applications and receiving application within the SOAP envelops.

As SOAP uses the simple http transport protocol, its messages are not got blocked by the firewalls.
REST

REST means REpresentational State Transfer; it is an architecture that generally runs over HTTP. The REST style emphasizes the interactions between clients and services, which are enhanced by having a limited number of operations. REST is an alternative to SOAP (Simple Object Access Protocol) and instead of using XML for request REST uses simple URL in some cases. Unlike SOAP, RESTFUL applications uses HTTP build in headers to carry meta-information.

There are various code that REST use to determine whether user has access to API or not like code 200 or 201 indicates successful interaction with response body while 400 indicates a bad request or the request URI does not match the APIs in the system. All API request parameters and method parameters can be sent via either POST or GET variables.

Rest API supports both XML and JSON format. It is usually preferred for mobile and web apps as it makes app work faster and smoother

There is one more thing one needs to learn
WSDL

WSDL (Web Services Description Language) is an XML based language which will be used to describe the services offered by a web service.

WSDL describes all the operations offered by the particular web service in the XML format. It also defines how the services can be called, i.e what input value we have to provide and what will be the format of the response it is going to generate for each kind of service.