Web services are the mechanism of communication through which two applications/machines exchange data, irrespective of their underlying architecture or technology.

Nowadays, you do not need to build applications from scratch to get information from heterogeneous sources. You can use web services directly to perform the intermediate task of calling and processing the data from these sources.

For example, if you want to display weather forecasts, you don’t need to collect and process the data in your application. Rather, you can use services from companies that are already processing and publishing weather information.

Web services can be implemented in different ways, but the following two are the most popular implementation approaches:

  1. SOAP (Simple Object Access Protocol)
  2. REST (Representational State Transfer Architecture)

SOAP is a standard protocol defined by the World Wide Web Consortium (W3C) standard for sending and receiving web service requests and responses. SOAP uses the XML format to send and receive the request; hence, the data is platform independent. SOAP messages are exchanged between the provider applications and receiving the application within the SOAP envelope.

REST is an alternative to SOAP, using simple URL instead of XML in many cases. Unlike SOAP, RESTful applications use HTTP built-in headers to carry meta-information. The REST style emphasizes the interactions between clients and services, which are enhanced by having a limited number of operations. RESTful API supports both XML and JSON formats. JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write with, and easy for machines to parse and generate. It is usually preferred for mobile and web apps as it makes applications work faster and smoother.

Like functional/performance test automation, we can automate the validation process of web services and reap the benefits of automation, such as:

  1. Reduced manual efforts in validating the web
  2. Less dependency of technical skills required for validating both SOAP-based and REST API-based web services
  3. More test coverage in shorter time windows

We can achieve the automation of web services in multiple ways. The first option is to write the scripts in the IDEs (Eclipse/Visual Studio) that use various open source tools/APIs like REST Assured used to test the web services. The second option is to create scripts directly within the tools like SoapUI Pro and Postman. Scripts written in these IDEs/tools do the following functions:

Collect the data: Gathers data used in the server request and the corresponding expected data received from the server.

  1. Send the request: Requests with specific data are sent to the server through the web services.
  2. Save the response: Response code and values of these requests are captured by the script.
  3. Validate the response: Code written in the scripts validate that for every specific request, and a unique response is received through the web services.
  4. Reporting: Validation results are shown in the execution reports after every execution run. Any deviation in expected response is flagged as a defect in the report.

The automation process remains the same for REST and SOAP services, but the data consumed in the process will change depending on the type of service.  While testing RESTful web services, Java scripts are created using either REST Assured or HTTP client to validate the response code (e.g. 200, 400, 500) obtained from the web service. The JSON data validates the expected and actual values returned from the web service.

In SOAP automation testing, the web services description language (WSDL) URL describes the operations offered by the particular web service in the XML format. This is used to validate the corresponding response of all operations performed by the web service.

Commercial tools for web service automation provide additional features such as data-driven testing, integration with CI/CD tools and email support. Less scripting is required with commercial tools because many include methods for sending the request, saving the response and validating response corresponding to specific requests.

Although API testing was not focused on much in the past, with the advancement of technologies, most organizations are seeing value in testing them thoroughly now. Subsequently, to reduce the effort for API testing, they are moving towards automating the process. Working with various clients over the years, Pyramid IT has garnered expertise in web service testing and designed a framework to automate the web services testing process for both REST and SOAP API’s. Use of open source tools makes this solution cost-effective and helps the clients achieve ROI in shorter time.

By Vikas Shukla December 19, 2018
Tags: Quality AssuranceSoftware testing