Skip to main content
search

© 2021 Excellerate. All Rights Reserved

Software DevelopmentTesting and QA

Testing Web Services and API with SoapUI – Introduction – Part 1

By October 13, 2015No Comments

Software development process has changed significantly over the last few years. Project follows Agile practices for the rapid deployment of disparate software into “Web services” offerings. Frequent updates to the “Web services” for adding new features and functions  gives rise to the Continuous Integration/Continuous Deployment (CICD). Automating Web Services/API testing is the most lucrative craft today from the business perspective.

Testing Web Services and API with SoapUIThese series of posts are intended for newbies who have interest in automating web services / API testing.

Before we dive deep, first let’s have a look on following fundamentals.
 
Web Service: It is a communication between two electronic devices over a network. It is a software function provided at a network address over the web with the service.
Web Service has an interface described in a machine-processable format (specifically Web Services Description Language). Other systems interact with the Web Service in a manner prescribed by its description using SOAP (Simple Object Access Protocol) messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.
API (Application Programming Interface):  It is a set of routines, protocols and tools for building software applications. It enables communication and data exchange between two separate software systems.  A software system implementing an API contains functions/sub-routines which can be executed by another software system.
API testing is entirely different from GUI testing and mainly concentrates on the business logic layer of the software architecture. It is a type of software testing that involves testing APIs directly and as part of integration testing to determine if they meet expectations for functionality, reliability, performance and security.
Difference between API and Web service: Both serve as a means of communication. The difference is that Web Service almost always involves communication over network and HTTP is the most commonly used protocol. Web service also uses SOAP, REST, and XML-RPC as a means of communication. While an API can use any means of communication. We can say that web service is an API wrapped in HTTP.
API Testing requires an application to interact with API. In order to test an API, you will need to use a testing tool like SoapUI to drive the API and write your own code to test the API.
Why SoapUI? : It is like a Swiss-Army Knife of testing. SoapUI is a free and open source cross-platform functional testing solution. With an easy-to-use graphical interface, and enterprise-class features, SoapUI allows you to easily and rapidly create and execute automated functional, regression, compliance and load tests. SoapUI works with all sorts of services such as SOAP, REST and XML-RPC, but there are some basic skills you should possess before using for actual testing.

  • You should have knowledge of SOAP and REST services.
  • You should be comfortable with reading XML/JSON, and understanding the affects of XML schema on web services designing and testing. Also, you should be competent of reading and writing xpath expressions.
  • You should able to read a WSDL file. In many cases you might need to dive deeper to understand the problem in your web services.

Here are some useful definitions for reference:

XML (Extensible Markup Language): XML is a markup language that defines a set of rules for encoding documents in a format which is both human-readable and machine-readable. [XML file example]

JSON (JavaScript Object Notation): JSON is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. [JSON file example]

XML schema: XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type. These constraints are generally expressed using some combination of grammatical rules governing the order of elements, Boolean predicates that the content must satisfy, data types governing the content of elements and attributes and more specialized rules such as uniqueness and referential integrity constraints. [XML Schema example]

XPath (XML Path Language): XPath is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers or Boolean values) from the content of an XML document. [Xpath Example]

WSDL (Web Services Description Language): WSDL is an XML-based interface definition language that is used for describing the functionality offered by a web service. WSDL file provides a machine-readable description about how the service can be called, what parameters it expects and what data structures it returns. [Example of WSDL file]

WADL (Web Application Description Language): WADL is a machine-readable XML description of HTTP-based web applications (typically REST web services). WADL is the REST equivalent of SOAP’s Web Services Description Language (WSDL), which can also be used to describe REST web services. [Example of a WADL description for the Yahoo News Search application]

HTTP Request Methods for RESTful Services: The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT and DELETE. These correspond to create, read, update and delete (or CRUD) operations, respectively.

Apart from these if you want to go extra mile and boost your SoapUI productivity even more, it is beneficial to learn about few concepts like Regex, Message Header, SQL and URI. In the next part we will have some insight of a sample project.
Thanks for reading! Let’s get started on our journey to Test Web Services and API with SoapUI.
References: