Forum Discussion

Umea_universite's avatar
Umea_universite
Occasional Contributor
12 years ago

[Res] Change WSDL with Groovy

Hello!

I wonder how I can change and reload the WSDL with a Groovy script? I have a teststep that builds the new endpoint string from two project parameters, like this:

def newEndpoint = "http://" + context.expand( '${#Project#host}' ) + ":8080/cxf/" + context.expand( '${#Project#serviceName}' );


and now I'd like to use the WSDL on that endpoint instead of the one I used when building the SoapUI project.



Regards,
Rikard

7 Replies

  • nmrao's avatar
    nmrao
    Community Hero
    You may open the project in the soapui:
    Select the service interface by double clicking it
    Go to Service Endpoints tab
    Set the endpoint to http://${#Project#host}:${#Project#port}/cxf/${#Project#serviceName}
    Click on assign and select the All requests and Test Request from drop down and click ok.

    And as you know already and doing, define & set the following parameters with the values at project level
    host
    port
    serviceName.

    And you do not need an additional groovy here.

    May be if the above is not the way you are looking for, please elaborate your use case.
  • Umea_universite's avatar
    Umea_universite
    Occasional Contributor
    I will certainly look into environment, Giscard, thank you.

    One thing though, I recall reading about a bug when changing environment from command line/testrunner (the -E argument). Is this true? I'm asking because we want to run all tests on Jenkins.

    Regards,
    Rikard
  • Hi Rikard,

    You're welcome. Unfortunately, there is a bug when changing the environment from TestRunner (ref. SOAP-1013). The fix has not been released yet. Sorry for the inconvenience.

    Regards,

    Giscard
    SmartBear Support
  • Umea_universite's avatar
    Umea_universite
    Occasional Contributor
    Alright, I see.

    So, back to my first question. Can I reaload the WSDL with a Groovy script?

    Cheers!
    Rikard
  • Umea_universite's avatar
    Umea_universite
    Occasional Contributor
    I think I worked it out for myself:


    import com.eviware.soapui.impl.wsdl.WsdlInterface
    myInterface = (WsdlInterface) testRunner.testCase.testSuite.project.getInterfaceByName("DegreeAppFacadeClientServiceSoapBinding")
    myInterface.updateDefinition("http://" + context.expand('${#Project#host}') + ":8080/cxf/" + context.expand('${#Project#serviceName}') + "?wsdl", false);
    log.info " WSDL definition loaded from '" + myInterface.getDefinition() + "'";


    Does that look good? Comments?
  • nmrao's avatar
    nmrao
    Community Hero
    Good, you could figure out.
    You are updating the definition, but what about the existing test cases, are they going to be updated in case if there is change in schema?
    What is exactly the use case if you dont mind?

    And do you want to save the project after wsdl update?