ChakriGurnath
9 years agoNew Contributor
Solution for "Parameterizing the Rest requests - GET & POST (body)".
My REST-GET request for "GetCapabilities" is:
http://EndPointName/ServiceName/ServiceType?Service=WFS&Request=GetCapabilities
The values of "EndPointName", "ServiceName" and "ServiceType" are never fixed, changes dynamically when run from Jenkins, so those values should be parameterized and taken from a configuration file.
Below is a solution for that problem:
- [Assuming that we are well versed with UI of tool SOAP UI]
- Create a standard Rest Project in SOAP UI using URI (having all the values as hard coded)
- Select the parent and say “Generate Test Suite”. Save the changes and exit soapui tool.
- Create a java project in eclipse and write a method to access flat files. Export the java project as "jar" and paste it to path "C:\Program Files\SmartBear\SoapUI-5.2.1\lib".
- Launch soapui tool and create a groovy type file (under test steps) to read the "Configuration.XML".
- Note: The custom config file should be created. Here, the explanation is with XML. We can even use properties file to read variables.
- Sample code snippet it:
import utility.* def path="C:\\TEMP\\Configuration.XML"; ServiceUtility SUtilityObj = new ServiceUtility(path); SQLQueries sqlQueriesObj = new SQLQueries(); //Assigning values to variables context["EndPointName"]=SUtilityObj.ReadConfigurationFile("C:\\TEMP\\ConfigurationFile.XML", "ENDPOINTNAME"); context["ServiceName"]=SUtilityObj.ReadConfigurationFile("C:\\TEMP\\ConfigurationFile.XML", "SERVICENAME"); context["ServiceType"]=SUtilityObj.ReadConfigurationFile("C:\\TEMP\\ConfigurationFile.XML", "SERVICETYPE"); context["ID"]="7673906";
- Edit the Get Request as below:
- Click on "Raw" tab to see an error reading "<missing raw request data>".
- Run the complete "Test Suite" to see the response.
- In the case of post body request, the post body should be mended as below: