Forum Discussion

sanathkd's avatar
sanathkd
Occasional Contributor
3 years ago

Error groovy.lang.MissingMethodException: No signature of method: java.lang.String.getService()

Below is my piece of automation code

 

def getEnv = project.getEnvironmentByName(env);
def wsdlInterface = project.getInterfaceAt( 0 ).getName();
def wsdlService = getEnv.getService(wsdlInterface, com.eviware.soapui.config.ServiceConfig.Type.Enum.forString("SOAP"));

 

Getting below error when trying to get service details for my automation.

.

groovy.lang.MissingMethodException: No signature of method: java.lang.String.getService() is applicable for argument types: (String, com.eviware.soapui.config.ServiceConfig$Type$Enum) values: [rentalDetails_V1_1PortTypeSoap11, SOAP]

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)

at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)

  • sanathkd ,

    These lines are expected to work perfectly, 

     

    def project=testRunner.testCase.testSuite.project
    def getEnv = project.getEnvironmentByName('test1');
    def wsdlInterface = project.getInterfaceAt( 0 ).getName();
    def wsdlService = getEnv.getService(wsdlInterface, com.eviware.soapui.config.ServiceConfig.Type.Enum.forString("SOAP"));
    log.info wsdlService.name

     Can you try looking at :
    ToolBar >> Environment Dropdown >> Configure Environments >> Choose your test environment >> Tab "SOAP" and make sure you have atleast one API/Service added there. If there's atleast one service, Since you're trying for index '0' it must give positive result. See image below.