Designing a SoapUI Framework for SOAP based Web Services Automation

Raghwendra Sonu
3 min readApr 23, 2020

--

Introduction

We are going to create SOAP based Framework using Groovy that will create Soap Request dynamically based on the data provided in the TestData sheet. This is using free version of the SoapUI.

Prerequisites

Install SoaupUI free version and add following jar files from internet,

in Lib folder:

dom4j-1.6.1.jar, xmlbeans-2.6.0.jar

in bin/ext folder:

commons-collections4–4.1.jar, commons-collections4–4.1-javadoc.jar, poi-3.16.jar, poi-examples-3.16.jar, poi-excelant-3.16.jar, poi-ooxml-3.16.jar, poi-ooxml-schemas-3.16.jar, poi-scratchpad-3.16.jar, writeevidence.jar, xmlbeans-2.6.0.jar

Folder Structure

keyStore- Keep All SSL certificates here.
output - Creates a folder for each run and store Request and Response of each test case from test data sheet.
projects - SOAPUIAutomationFramework will be there, which needs to be imported in SoapUI
sampleXML - sample xmls of Soap request will be created in this folder, which are used to create dynamic Soap Request
testData - SOAPUIAutomationFramework.xlsx will be there, which is source of test data

Download the Project

The link to download the project is here:

https://github.com/raghwendra-sonu/SoapUIFramework/tree/master/SoapUIWorkspace/projects

Import the project into SoapUI

Launch SoapUI tool and import the project to your workspace.

There will be only one project (SOAPUIAutomationFramework), one testsuite (WebServiceTestSuite) and one test case (WebServiceTest). And following test steps will be there in the test case. All test steps should be in this sequence:

> createFolder
> bootstrap
> sampleXML
> pushSampleRequest
> testData
> requestSample
> transformXml
> pushFinalRequest
> WebServiceTest
> writeReq&Res
> statusWrite
> getNextStep
> End

Add WSDL in project

Add WSDL in project which has to be tested. User can add multiple WSDLs in one project, no need of creating multiple projects, testsuites or test cases.

Test Data/ Test Cases preparation

There will be only one test data excel sheet (same name as SoapUI project name, SOAPUIAutomationFramework.xlsx)There will be only one worksheet (same name as test case name in SoapUI, WebServiceTest). Following columns are there in test data sheet.

  • Execute — Y (include as part of run), N (do not include as part of run). Only this column has fixed position (0).
  • WebService — enter Web Service name, exactly same from SoapUI
  • Operation — enter operation name, exactly same from SoapUI
  • EndPoint — enter end point of web service
  • UserName — enter user name if user authentication is requied.
  • Password — enter corresponding password for the given username
  • KeyStore — This is for SSL certificates. Copy your certificate in keyStore folder, and enter the name of the same in this column
  • KeyPass — enter password of KeyStore certificate
  • Env — Enter environment Name
  • Test Case — enter test case name/description
  • Data1 to Data…n — These are the test data for soap request. User needs to provide data in the form of “KEY,VALUE”. Where key is text node name and value is text/string which user wants to pass in it
  • Expected1 to Expected…n — These are the validations with soap response. User needs to provide data in the form of “KEY,VALUE”. Where key is node name and value is text/string which user wants to validate to pass or fail the test
  • Status — This column will be filled after the test run. Values will be PASSED, FAILED and empty(if Execute is N)

Note -

  • Framework creates Soap Request dynamically based on the data provided in DATA columns.
  • Data and Expected columns accept direct node name, xpath, list node (need to provide with indexing)
  • ‘#KEEP’ is a keyword, if user wants to keep the text node in soap request with empty/null value. e.g ‘username;#KEEP’ . in this scenario username will be part of Soap Request but with empty value.
  • ‘#EXISTS’ is a keyword, if user wants to validate a dynamic value in Soap Response. e.g. ‘transactionNumber;#EXISTS’. In this scenario system checks if provided node is present in Response or not and it should not be empty.

Add n number of test cases in one test data sheet.

Running the tests

You can run the test directly from SoapUI, create a .bat file and create a Task scheduler in windows or .sh file and write a cron job in ubuntu machine.

Close the test data sheet while running the test.

Test Data sheet will be updated with PASSED or FAILED status once test will be completed.

Stats

This framework can execute 600 test cases in 1 hour, or even more based on your system tps.

--

--

Raghwendra Sonu

Software Automation Testing expert with 9 years of work experience in diverse tools and technologies.