Webservices

What web services are

In the broad sense of the word, a web service is a method that two applications use to communicate over the Internet.

It can be interaction between applications on a smartphone, between computers or other devices.

Another popular term close in meaning to web services is API

Web services are used where direct integration is impossible.

Example №1: if you want to put Yandex maps on your site you do not have to install programs from Yandex, it is enough to send a few requests and Yandex will pass on the information you need. This is possible because the programmers have developed a special set of requests that you can send to their server to get a map back.

Example №2: there is a situation where a site written in PHP wants to use the functionality of a site written in .NET. They need to exchange messages somehow, because .NET will not understand PHP commands and vice versa.

To get around this problem the programmers agreed to use special messages that do not depend on the programming language and are based on the HTTP protocol (because data exchange over the Web goes over HTTP).

The format of these messages is either JSON or XML. We will talk about them later.

Let us repeat the point: the idea is that a site written in PHP does not send its partner any PHP commands; a message in an agreed format is sent to a pre-arranged address.

The address to which the messages are sent is called an Endpoint. Usually it is a URL (for example, the name of the site) and a port. If I want to create a web service on port 8080 the Endpoint will look like this:

http://aredel.com:8080

If my web service has to answer various messages I will create several URLs (interfaces) through which the service can be reached. For example

http://aredel.com:8080 /resource1/status
http://aredel.com:8080 /resource1/getserviceInfo
http://aredel.com:8080 /resource1/putID
http://aredel.com:8080 /resource1/eventslist
http://aredel.com:8080 /resource2/putID
...

As you can see, my Endpoints have different endings. Such an ending in an Endpoint is called Resource, and the beginning Base URL.

Endpoint = Base URL + Resource

Once all these interfaces are created they have to be described. There has to be a document that makes it clear

This document has to be available to the programmers on both sides, otherwise they simply will not be able to agree and implement a working web service.

Let us go back to the first item of the list, namely to what methods.

The HTTP protocol provides several ways to send a request to the same Endpoint. They are called CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE; you can read about their properties here.

Once we know which methods can be used with which Endpoint, making up requests is not difficult. For example:

GET http://aredel.com:8080 /resource1/status
GET http://aredel.com:8080 /resource1/getserviceInfo
PUT http://aredel.com:8080 /resource1/putID
GET http://aredel.com:8080 /resource1/eventslist
POSThttp://aredel.com:8080 /resource1/eventslist
PUT http://aredel.com:8080 /resource2/putID
...

So, the simplest request consists of a method and an Endpoint

Request = Method + Endpoint


Calculator. Http methods. Protocols/rfc2616.

↓ Articles about Testing ↓
API testing lessons
API testing
Testing with Python
Selenium + Python
SOAP UI
JMeter
Bash for QA Engineer
Clumsy 0.2
Python script for ZPL
Python Sockets
Integration Testing

Article author: Andrei Olegovich