Forum Discussion

ChakriGurnath's avatar
ChakriGurnath
New Contributor
8 years ago

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:

    1. [Assuming that we are well versed with UI of tool SOAP UI]
    2. Create a standard Rest Project in SOAP UI using URI (having all the values as hard coded)
    3. Select the parent and say “Generate Test Suite”. Save the changes and exit soapui tool.
    4. 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".
    5. Launch soapui tool and create a groovy type file (under test steps) to read the "Configuration.XML".
    6. Note: The custom config file should be created. Here, the explanation is with XML. We can even use properties file to read variables.
    7. Sample code snippet it:
    8. 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";
    9. Edit the Get Request as below:
    10. Click on "Raw" tab to see an error reading "<missing raw request data>".
    11. Run the complete "Test Suite" to see the response.
    12. In the case of post body request, the post body should be mended as below:

 

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Is there any question in this? Or are you sharing the solution?
    • ChakriGurnath's avatar
      ChakriGurnath
      New Contributor

      Mr Rao,

      I shared a solution.

      Can you guide me if I happened to post in a wrong place because I have a couple more to share.