While working on Implementation Projects, many a time we need to call a web service multiple times for same purpose using web services testing tools like SOAP UI.
Let us take example of BI cloud connector(BICC). We configure BICC to upload the extracts to UCM and from UCM a third party application will fetch these files. Sometimes when there is any issue we need to delete these files. We will have lot of extracts in BICC and hence the count of files sometimes will be 300+.
Below are some of the possible options to delete these files
1). Go to content server and delete the files one by one
2). Call generic SOAP service to delete the files based on DOC ID one by one.
3). Create Test Suite in SOAP UI and use Groovy to call the Point 2 multiple times
When can also take example of Customer data conversion where customer profile was not created and if count of customer accounts are huge then we can use the Groovy script to call the customer profile creation Web service multiple times.
Let us understand in detail how we can achieve the automation of Web service call in SOAP UI using Groovy(Example: Deleting files from UCM).
- We will create a simple data model and report that will fetch us the Doc ID's from UCM which needs to be deleted using the Fusion UCM tables mentioned in this link.
- Export the output in file eg. csv
- In SOAP UI create a SOAP Project->Test suite->test case->Test Steps-> (a) Properties (b). Groovy Script (c). SOAP Request
- Run the test case/suite or Run Groovy script step
- Create a data model and report to fetch the Doc Id's of the documents which needs to be deleted.
- View the data and save as sample data. Save the Data model.
- Now Create a report to get all the doc Id's( The data model has limit to display only 200 records and also we cannot get csv output from data model, it exports to only XML).
- In the next window, click on cancel. We will use the generate RTF option, which is the easies one.
- Select the data model by clicking on search icon.
- Now click on "Generate RTF layout based on selected Data Model." Provide template name and click on generate. RTF template will be created automatically.
- Now we need to set the default output to Data(CSV), so click on "View a list" and Add the "Data(CSV) by checking the checkbox in output formats and change the default output from HTM to Data(CSV).
- Click on "View Report". The output will be generated, export the output to CSV.
- Now we have the csv file with the list of Doc Id's from UCM which needs to be deleted.
- We will now see how we can use this file in Soap Ui to call the webservice multiple times
- Open SOAP UI
- Create a new SOAP Project, provide the necessary details and click on ok.
- Now Create a Test suite, under this project. For this right click on the Project and then click on New TestSuite as shown in below screenshot.
- Now we will create "Test Case" under the Test Suite. Right click on "delete_ucm_doc" test suite and then click on "New TestCase".
- Till now we have created a SOAP Project, Test Suite and Test Case.
- Now we need to add the test steps to the test case.
- We will have 3 test steps. Add these steps one by one.
- Now we are done with the setups. We can either run the test case or we can directly run the groovy script to call the SOAP request multiple times as the SOAP request is getting called inside for loop with limit as number of doc id's in the file.
- If we run the test case we would get the below screen on successful completion.
- If we run Groovy script then we would get below.
- Similarly we can automate Rest Api calls as well.
No comments:
Post a Comment