Forum Discussion

mamar's avatar
mamar
Contributor
11 years ago

create a project dynamically with wsdl with groovy

Hi,

I need to create a soap project dynamically from one of my test run. I read this post from soapui http://www.soapui.org/Developers-Corner/integrating-with-soapui.html and was trying to create a project with the existing wsdl file. I followed the same process, but getting an error. Can anyone help me on how to create a project with an existing wsdl, with its operations?.

My code looks like below.

import com.eviware.soapui.impl.wsdl.*
import com.eviware.soapui.impl.WsdlInterfaceFactory

project = new WsdlProject()
//wsdl = new WsdlInterfaceFactory()

project.setName("Test");
WsdlInterface iface = WsdlInterfaceFactory.importWsdl(project, "C:\\junk\\AcctInq_v2_1.wsdl", true)[0];


and the error i get is
com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
  • Giscard,

    I have did the wsdl analyzer but did not get any errors. Could you please help me to resolve this?
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    If you are working outside of SoapUI itself check out this thread. It is some snippets of a Java project I created that builds SoapUI project files from WSDLs. It also gives the ability to parse the XML a bit but it's a bit older.


    If you are working within SoapUI

    import com.eviware.soapui.impl.wsdl.teststeps.registry.*;
    import com.eviware.soapui.impl.wsdl.teststeps.*;
    //Uncomment below to import WSDLs
    //import groovy.io.FileType

    //def list = []

    //def dir = new File("C://WSDLS")
    //dir.eachFileRecurse (FileType.FILES) { file ->
    // list << file
    //}

    //for ( file in list ) {
    // testRunner.testCase.testSuite.project.importWsdl(file.toString(),true)
    //}
    def testSuiteName = "TestSuite";
    EWHtestSuite = testRunner.testCase.testSuite.project.addNewTestSuite(testSuiteName);
    for (iFace in testRunner.testCase.testSuite.project.getInterfaceList()) {
    if (iFace.getName().matches(".*?[0-9]")) {
    EWHtestCase = EWHtestSuite.addNewTestCase(iFace.getName());
    EWHtestCase.setKeepSession(true);
    log.info EWHtestCase.addTestStep(((WsdlTestStep)testRunner.testCase.getTestStepByName("Login")).getConfig())
    for (operation in iFace.getOperationList()) {
    TStepC = WsdlTestRequestStepFactory.createConfig(operation, operation.getName());
    testStep = EWHtestCase.addTestStep(TStepC);
    }
    }
    }