What are Web Services?
A web service is an application hosted on a server that, in addition to its primary purpose, is designed to support the interaction between two machines over a network and allow information to be exchanged between them. Any service and web service is considered to be:
Available online or (internal network)
Uses a standardized messaging system
It is recognized by the search engine
Not related to the operating system or programming language
Web Services is published in a unique location where they are offered as services. UDDI (Universal Description, Discovery and Integration) is a centralized location that provides a mechanism for registering and retrieving Web services. UDDI uses SOAP for communication and allows clients to find the service as well as the server to publish it.
Services may be closed (private) but also publicly available. You can view the list of publicly available services in the github repository or at https://www.publicapis.com. Some well-known public services are:
Web services have the ability to describe themselves, and WSDL (Web Service Description Language) is used to describe the service. WSDL is written in XML and contains information about where the web service is located and what communication protocol it uses.
Web services in collaboration with the desktop GUI application
Web services in conjunction with the desktop GUI application are something between the web and desktop applications. The web server service provides functionality and the desktop application provides a customizable graphical interface. Communication between them is accomplished using XML or JSON format. Web service in conjunction with the desktop GUI application is more flexible than the web application because the user can customize the appearance of the application on the desktop while the web application user has to use a web browser and has no effect on how the application will look on the screen.
Advantages over web application:
They are more economical in terms of network load and server resources, since they only send a response when communicating, while web applications send HTML in addition to the response, with the form and description of how the address should be displayed. Web services are ideal for “small” devices other than PCs, ie mobile Pocket PCs … because only front-end application is installed on such device and the hard part is done on the server.
They are easier to develop, test and maintain. With the Web application, in addition to the necessary functionality, it is necessary to test the design on all browsers and platforms, while for web services the author only cares about the function while the view is taken care of by the client application.
Web service types
The main protocol for transporting data between a web service and a client is HTTP, although other protocols can be used. The data format is XML or JSON.
Big Web Services (aka SOAP-based Services)
These services follow SOAP standards and the data is transmitted in XML format and is described by WSDL. Using the SOAP protocol enables the communication between applications on different operating systems and different technologies by exchanging messages in an “agreed upon” format.
There are several different types of messages in SOAP, the most famous being Remote Procedure Call (RPC). This is the type of message in which one node in a network (client) sends a request to another node (server), after which the server returns a response to the received request. This protocol is the successor of the XML-RPC protocol. It uses the same rules for transport but has a different message structure.
Areas, where SOAP-based services are well-managed, are:
Formal contracts where both parties need to agree on a format for the exchange of information for operations that use states
The disadvantage of SOAP-based services is a complexity and over-extensive use of XML, although this disadvantage does not prevent Microsoft and IBM from using it very often. Disadvantages are also considered resource consumption to parse XML.
SOAP (Simple Object Access Protocol) is a communication protocol used to describe messages between applications. The SAOP protocol defines and prescribes the message format for communication. A SOAP message is a simple XML document that consists of the following elements:
The Envelope element (identifying the XML document as an SAOP message) is a required part
The header is an optional part
The body is the required part and carries information (parameters) of the request and returns the results, ie the response of the Web service.
Fault element that is optional and provides information on what to do if an error occurs while processing the message
RESTful web services
These services are more easily integrated with HTTP than SOAP services, they do not require XML messages or WSDL service descriptions. Today, RESTfull stands out as the dominant network service, suppressing SOAP and WSDL because it is significantly easier to use.
The data is most commonly transferred in JSON format, although XML and YAML are also available. Based on REST architecture, it is very flexible and easy to understand. It can be executed on any client or server that has HTTP / HTTPS support. RESTful services should have the following features and features:
Uniform interface URI
Explicit use of HTTP methods
XML and / or JSON transfer
With this type of service, resources (eg static pages, files, database data…) have their own URL or URI that identifies them. Access to resources is defined by the HTTP protocol, where each call does one action (create, read, modify, or delete data). The same URL is used for all operations, but the HTTP method that defines the type of operation changes. REST uses “CRUD like” HTTP methods such as GET, POST, PUT, DELETE, OPTIONS.
Application of RESTfull service
RESTfull services are used by:
with limited bandwidth and resources (feedback can be in any form)
for operations that do not use states (if an operation needs to be continued then REST is not the right approach and SOAP is probably a better solution)
in situations where caching is possible (if information can be cached for non-state operations then this approach is great)
Advantages of RESTfull service
Clients calling REST services do not have to format requests according to the SOAP specification and do not have to parse the SOAP response to get a result from it.
the flexibility of the format of the returned data
use of existing network infrastructure quickly mastering the technique
REST is not a protocol as SOAP but a concept based on changing the client’s state and all actions are performed at the moment of changing that state, with the possibility of returning to one of the previous states.
The REST architecture typically consists of a client and a server. The client initiates the request to the server, the server processes the request and returns the response to the client.
Web Services Based on POX (Plain Old XML)
There is a growing trend for pragmatic developers to use Plain Old XML with the “REST like” URL and best of SOAP protocols. This service uses “raw” XML for data transmission, and GET and POST methods for communication. When it is said that it uses raw XML the thought is not wrapped in any other envelope of a message protocol. This type of service is simpler and faster than SOAP service, and has retained the “strongly-typed API” which is the biggest advantage of SOAP service.