SoapUI how to Update WSDL Definition and Recreate requests through Groovy Script

groovysoapui

I have a soap test Project in SoapUI. I have added all the requests as test steps in a test suite.

I need that the WSDL definition gets updated and requests get recreated (while keeping existing values) every-time i start the test.

I need help to do this process automatically with help of a groovy script that can be placed inside the project and runs every-time before execution starts.

Best Answer

Got it working now.. Here is the complete code..

import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests
import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests

project = testRunner.testCase.testSuite.project; //get the project reference
def ifaceList = project.getInterfaceList(); //get all the interfaces present in the project in a list

//start a loop for number of interfaces
for(int i = 0; i < project.getInterfaceCount() ; i++)
{

def iface = project.getInterfaceAt(i);
def url = iface.definition;
iface.updateDefinition( url, true); //updateDefinition(String url , Boolean createRequests)

//The above part updates the definition
//The part below recreates the requests based on updated wsdl definition

//syntax - 
//recreateRequests( WsdlInterface iface, boolean buildOptional, boolean createBackups, boolean keepExisting, boolean keepHeaders )

recreateRequests(iface,true,true,true,true);
recreateTestRequests(iface,true,true,true,true);
}
//End of Script//

Hope this helps others looking for similar solution.

Related Topic