Forum Discussion

ME_Bank_Support's avatar
ME_Bank_Support
Occasional Contributor
10 years ago

Dynamic WSDL definition update and update test request

Hello

i want to know how to update WSDL definitions dynamically and update the test requests in the test suit if any definition updated. I know we can do this manually but we got too many WSDl definitions and communication is really bad among different providers. So we don't know when and which definition is getting updated so unable to do it manually. when running the targeted test suit i need to update the latest definition first and then run the test suit on the updated test requests. I created a groovy script but its not working as expected. Is there any better way to implement this or can you please correct my script especially the parameters that i am passing to Create test request function.

import com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction;
import com.eviware.soapui.impl.*;
import com.eviware.soapui.impl.wsdl.*;
import com.eviware.soapui.config.*;
import com.eviware.soapui.config.InterfaceConfig.Factory;
import java.net.*;
import java.io.*;
import java.lang.*;


InterfaceConfig config = InterfaceConfig.Factory.parse(new URL("http://wbmgwy1-dev3.metest.local:8655/ws/MEB_SM_ProductMgmt.WS.provider.v1:ProductService?WSDL"));
WsdlProject project = new WsdlProject("S:\\Change & Technology\\Transformation Project\\04 Projects\\11 Origination\\06 .Test\\R2 System Testing\\04 Test Scripts\\Services Testing\\workspace\\Prasanth-soapui-project.xml");
def li= project.getInterfaceList()
log.info li.size()
Iterator iter=li.iterator()
while(iter.hasNext()){

Object element=iter.next()
log.info element.getName()
// log.info element.get
//element.reload()
log.info element.getInterfaceType()


def nli1=com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests( element,false,false,true,false)
def nli=com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests( element,false,false,true,false)

log.info nli.size()
Iterator iter1=nli.iterator()
while(iter1.hasNext()){

Object element1=iter1.next()
log.info element1.getName() }
// log.info element.getDefinition()
// element.updateDefinition(

}
project.save()
project.release()

8 Replies

  • ME_Bank_Support's avatar
    ME_Bank_Support
    Occasional Contributor
    hello Temil

    I think you didn't understand my question completely. I want to update my definitions dynamically when running a test suit. usually u right right click on the WSDL definition and update definition and select update test requests also. I want to automate this process. I want to update the definitions and update my test requests before i run the suit so that they fail.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    The problem is that this feature is not available out of the box. It is probably achievable via groovy scripting but unfortunately we do not have enough resources to provide groovy script for this issue. If you'd like I can submit a feature request for this. Please let me know your thoughts.

    Regards,
    Temil
  • ME_Bank_Support's avatar
    ME_Bank_Support
    Occasional Contributor
    That will be really good. I already got the groovy script for this and i shared it already. All i want is can some one have a look at that and tell mw what the problom is. I am not comfortable with the parameters that i am passing in the below function. Please have a look and get back to me. Any help is appreciated.

    def nli1=com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests( element,false,false,true,false)
    def nli=com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests( element,false,false,true,false)
  • nmrao's avatar
    nmrao
    Champion Level 3
    Here is the groovy script:

    import com.eviware.soapui.impl.wsdl.WsdlInterface
    import com.eviware.soapui.impl.wsdl.WsdlProject
    import com.eviware.soapui.model.iface.Interface

    import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests
    import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests
    /**
    * Created by nmrao on 12/24/14.
    */
    class UpdateWsdls {

    WsdlProject wsdlProject

    public UpdateWsdls(String projectFileName) {
    this.wsdlProject = new WsdlProject(projectFileName)
    }

    def getBindingNames(String wsdlFile) {
    def definitions = new XmlParser().parse(new File(wsdlFile))
    return definitions.getByName('*:binding').@name
    }

    void updateInterfaceDefinitions(List<String> wsdlFileNames) {
    wsdlFileNames.each { fileName ->
    def interfaceNames = getBindingNames(fileName)
    interfaceNames.each {
    updateInterfaceDefinition(it, fileName)
    }
    }
    }

    void updateInterfaceDefinition(String interfaceName, String fileName) {
    List<Interface> interfacesList = wsdlProject.interfaceList
    interfacesList.each { Interface anInterface ->
    if (anInterface instanceof WsdlInterface && interfaceName.equals(anInterface.name)) {
    WsdlInterface wsdlInterface = (WsdlInterface) anInterface
    wsdlInterface.updateDefinition(fileName, false)
    }
    }
    }

    void updateRequests () {
    List<Interface> interfacesList = wsdlProject.interfaceList
    interfacesList.each { Interface anInterface ->
    WsdlInterface wsdlInterface = (WsdlInterface) anInterface
    recreateRequests(wsdlInterface,false,false,true,false)
    recreateTestRequests(wsdlInterface,false,false,true,false)
    }
    }

    void saveWsdlProject() {
    wsdlProject.save()
    wsdlProject.release()

    }

    }

    String projectName = "/path/to/abc-soapui-project.xml" //absolute path of soapui project file
    List<String> wsdlFiles = ["/path/to/service1.wsdl"] //or you can have multiple wsdls from different wsdl files which you want to update in one project
    UpdateWsdls updateWsdl = new UpdateWsdls(projectName)
    updateWsdl.updateInterfaceDefinitions(wsdlFiles)
    updateWsdl.updateRequests()
    updateWsdl.saveWsdlProject()
      • nmrao's avatar
        nmrao
        Champion Level 3
        Have a backup of the project and give it a try to see if that helps.