Forum Discussion

Grrison's avatar
Grrison
Occasional Contributor
9 years ago

how to set SOAP and REST Service Endpoint into Environments from Groovy

Hi All,

 

We would like to create a set of Environments and fill in SOAP, REST services, Properties from Groovy scripts. 

I tried the codes below, but the Endpoint field of Environment cannot be filled in.

 

ServiceImpl SOAPService = env.addNewService("SOAPService",com.eviware.soapui.config.ServiceConfig.Type.SOAP);

EnvironmentEndpointConfigImpl SOAPepConfigImp = (EnvironmentEndpointConfigImpl)EnvironmentEndpointConfig.Factory.newInstance();
SOAPepConfigImp.setLabel("http://localhost:8080");
EndpointImpl SOAPep = new EndpointImpl( SOAPepConfigImp ,SOAPService);
SOAPService.setEndpoint(SOAPep);

 

Regards,

Grrison

 

 

 

5 Replies

  • Grrison's avatar
    Grrison
    Occasional Contributor

    I found WsdlProjectPro has addNewEnvironment() could be used to add new Environment.

  • Grrison's avatar
    Grrison
    Occasional Contributor

    I got following warning message:

     

    Mon Sep 07 15:54:35 CST 2015:WARN:No service found for name 'SOAPService' in project com.eviware.soapui.impl.wsdl.WsdlProjectPro@4e95a079

     

    But, I think the SOAPService should be there, since it is created in env.addNewService("SOAPService",...);

      • Grrison's avatar
        Grrison
        Occasional Contributor

        it seems not exactly my issue.  I would like to create Multiple Environments in one project by accessing ReadyAPI object model, such as below

        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);

        newEnv is a Environment object from WsdlProjectPro.addNewEnvironment("env_Name"); 

        but after setting the Endpoint statement, there is nothing in the "Endpoint" column of new added SOAPService in Environment windows. 

        Just want to know how to set the Endpoint of SOAPService/RESTService in Environments.

         

        Regards,

        Grrison