Unable to call Java method using groovy script
All,
I have created jar file with name readXML.jar and placed the jar file in bon/ext folder. I have the imported the package and called the required java method as below
import readXML.readXMLResponse
def StrXML=context.testCase.testSuite.project.testSuites["Services"].testCases[ServiceName].testSteps[methodname].getPropertyValue("ResponseAsXML").toString();
log.info StrXML;
def tagname=context.testCase.testSuite.getPropertyValue("OUTPUTTAG")
log.info "tag name is :$tagname"
readXMLResponse xml1= new readXMLResponse();
ArrayList alist=new ArrayList();
alist=readXMLResponse.GetData(StrXML,tagname);
During execution in soapui, I am getting below error. Note I checked calling this method in eclipse and it worked fine.
ERROR:groovy.lang.MissingMethodException: No signature of method: static readXML.readXMLResponse.GetData() is applicable for argument types: (java.lang.String, java.lang.String)
Please find the attached document that contains content of the jar file.
Thanks,
Ravindra
- From the error & attachment, there is not static method in the java class
- Create the class object & then call the method
- It is directly not relevant, but just providing the feed back on the naming conventions
- class name should use Init Caps. Say : ReadXmlResponse
- method name should start with lower case and followed by Init Caps. Say : getData()
- in this case, the method can be static
If you want to process the xml, you do not have to use java which needs lot of instruction, instead use groovy and is very easy to do it.
You can find some samples below:
https://github.com/nmrao/soapUIGroovyScripts/search?utf8=%E2%9C%93&q=xml&type=