Briefly about web services
Definition
A web service is an application hosted on a server, which, in addition to its basic purpose, is designed to support the interaction between two machines over a network and enable the exchange of information between them. Every service and web service is considered to be if:
. Available online or (internal network)
. Uses a standardized messaging system
. It is recognizable by the search engine
. It is not related to the operating system or programming language
Service search
Web Services are published in a unique location where they are offered as services. UDDI (Universal Description, Discovery and Integration) is a centralized site that provides a mechanism for registering and finding Web services. UDDI uses SOAP for communication and allows clients to find the service as well as the server to publish it.
Services can be closed (private) but also publicly available. You can see the list of publicly available services in the github repository or at https://www.publicapis.com. Some well-known public services are:
Service description
Web services have the ability to describe themselves, and Web Service Description Language (WSDL) is used to describe the service. WSDL is written in XML and contains information about where the web service is located and which communication protocol it uses.
Web services in cooperation with desktop GUI application
Web services in conjunction with a desktop GUI application are something between a web and a desktop application. The web service on the server provides functionality and the desktop application provides a customizable graphical interface. Communication between them is achieved using XML or JSON format. The web service in cooperation 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 user of the web application must use a web browser and has no influence on how the application will look on the screen.
Advantages over the web application:
- They are more economical in terms of network load and server resources because they only send a response when communicating, while web applications send HTML in addition to the response with a form and description of how the response should be displayed. Web services are ideal for “small” devices that are not PCs, ie mobile Pocket PC… because only a front-end application is installed on such a device, and the hard part is done on the server.
- They are easier to develop, test, and maintain. In the case of a web application, in addition to the necessary functionality, it is necessary to test the design on all browsers and platforms, while in the case of web services the author only takes care of the function, while the client application takes care of the display.
Types of web services
The main protocol for transporting data between the web service and the client is HTTP, although it is possible to use other protocols. The data transfer format is XML or JSON.
a) Big Web Services (so-called SOAP-based services)
These services follow SOAP standards and the data is transmitted in XML format and described in WSDL. The use of the SOAP protocol enables the communication between applications on different operating systems and different technologies by having applications exchange messages of the “agreed” format.
There are several different types of messages in SOAP, the most famous being the Remote Procedure Call (RPC). It is a type of message in which one node in the 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 to the XML-RPC protocol. It uses the same transport rules but has a different message structure.
Areas in which SOAP-based services work well are:
- in formal agreements when both parties need to agree on a format for exchanging information
- in operations that use states
The disadvantage of SOAP-based services is the complexity and excessive “extensiveness” of using XML, although this disadvantage does not prevent Microsoft and IBM from using it very often. The disadvantages are also considered to be 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 format of messages for communication. A SOAP message is a plain XML document that consists of the following elements:
The envelope element (identifies the XML document as an SAOP message) is a required part
A header that is an optional part
The body is a mandatory part and carries the 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
b) RESTful web services
These services are more easily integrated with HTTP than SOAP services, do not require XML messages or WSDL service descriptions. Today, RESTfull has stood out as the dominant network service, supplanting SOAP and WSDL because it is significantly easier to use.
Characteristics
Data is usually transferred in JSON format although both XML and YAML format are available. Based on the 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 characteristics:
- Stateless
- Cacheable
- 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. Resource access is defined by the HTTP protocol, where each call makes one action (creates, reads, modifies, or deletes data). The same URL is used for all operations but changes the HTTP method that defines the type of operation. REST uses “CRUD-like” HTTP methods such as GET, POST, PUT, DELETE, OPTIONS.
Application of RESTfull service
RESTfull services are used:
- 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 the information can be cached due to operations that do not use states then this approach is excellent)
Advantages of RESTfull service
The features of the RESTfull service are:
- simplicity (Clients calling REST services do not have to format SOAP specification requests and do not have to parse the SOAP response to get the result.)
- the flexibility of the format of the returned data (The format in which the data is returned is not predefined and depends on the service itself. Clients can request data in the format that suits them best, unlike the SOAP format which, although standardized, must be parsed. So JavaScript can get data in JSON format that it can easily read, and an RSS reader in RSS-XML format that it can display.)
- use of existing network infrastructure
- quick mastery of techniques
REMARK:
REST is not a protocol like SOAP, but a concept that is based on changing the state of the client and all actions are performed at the time 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 a response to the client.c) Web services based on POX (Plain Old XML)
c) Web services based on POX (Plain Old XML)
There is a growing trend among pragmatic developers to use Plain Old XML with a “REST-like” URL and the best from the SOAP protocol. This service uses “raw” XML for data transfer, and GET and POST methods for communication. When it is said to use raw XML the thought is not enveloped by any other envelope of any messaging 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.