Forum Discussion

UhsBat's avatar
UhsBat
Occasional Contributor
5 years ago

How to create object of EnvironmentEndpointConfig

I have a readyAPI project  and it has only default environemnt. I want to create a new environment(DEV) and add all the services using groovy. I searched some code, but it fails to cast url to EnvironmentEndpointConfig. 

 

import com.eviware.soapui.model.environment.ServiceImpl
def wsdl = testRunner.testCase.testSuite.project.getInterfaceAt(0)
def newEnv = testRunner.testCase.testSuite.project.addNewEnvironment("ABC")

def nameofService =  testRunner.testCase.testSuite.project.getInterfaceAt(0).name

ServiceImpl soapService = newEnv.addNewService(nameofService, com.eviware.soapui.config.ServiceConfig.Type.SOAP)
URL url = new URL(wsdl.getDefinition());
com.eviware.soapui.config.EnvironmentEndpointConfig epConfig = com.eviware.soapui.config.EnvironmentEndpointConfig.Factory.parse(url);
EndpointImpl epImpl = new EndpointImpl(epConfig, soapService);
soapService.setEndpoint(epImpl);

Please guide me 

  • Finally it worked, I just created a string and converted into  EnvironmentEndpointConfig 

     

    def str = '<xml-fragment authProfile="No Authorization" username="" password="" domain="" incomingWss="" outgoingWss="" wssTimeToLive="" wssType="" proxyHost="" proxyPort="" proxyUsername="" proxyPassword="" xmlns:con="http://eviware.com/soapui/config">' + NewUrl+ '</xml-fragment>'
    com.eviware.soapui.config.EnvironmentEndpointConfig epConfig = com.eviware.soapui.config.EnvironmentEndpointConfig.Factory.parse(str);
    EndpointImpl epImpl = new EndpointImpl(epConfig, soapService);
    soapService.setEndpoint(epImpl);

     

      • UhsBat's avatar
        UhsBat
        Occasional Contributor

        Finally it worked, I just created a string and converted into  EnvironmentEndpointConfig 

         

        def str = '<xml-fragment authProfile="No Authorization" username="" password="" domain="" incomingWss="" outgoingWss="" wssTimeToLive="" wssType="" proxyHost="" proxyPort="" proxyUsername="" proxyPassword="" xmlns:con="http://eviware.com/soapui/config">' + NewUrl+ '</xml-fragment>'
        com.eviware.soapui.config.EnvironmentEndpointConfig epConfig = com.eviware.soapui.config.EnvironmentEndpointConfig.Factory.parse(str);
        EndpointImpl epImpl = new EndpointImpl(epConfig, soapService);
        soapService.setEndpoint(epImpl);