cancel
Showing results for 
Search instead for 
Did you mean: 

Modularize the soapui test suites: Groovy script in eclipse, create a jar file & call it into soapUI

itsmylife
New Contributor

Modularize the soapui test suites: Groovy script in eclipse, create a jar file & call it into soapUI

I need to create a sample Soap request by calling the endpoint URL and give the necessary login and password info and then send a request and get a response in XML. I'm writing the groovy script in eclipse IDE and creating a jar file and call that jar file into SoapUI and call the code within the jar file into SoapUI.

 

I am getting an error and how should I resolve this? Is there any other way to achieve my goal? Please help me.

 

The Output:

Caught: groovy.lang.GroovyRuntimeException: This script or class could not be run. It should either: - have a main method, - be a JUnit test or extend GroovyTestCase, - implement the Runnable interface, - or be compatible with a registered script runner. Known runners: * org.apache.groovy.plugin.DefaultRunners$Junit3TestRunner * org.apache.groovy.plugin.DefaultRunners$Junit3SuiteRunner * org.apache.groovy.plugin.DefaultRunners$Junit4TestRunner

 

Here is the code:

package com.xyz.demo

class ABC {
public setUP() {
    // set data
    def url = new URL("https://qwertywq.asmx").openConnection();
    if(soapaction != null) connection.setRequestProperty("SOAPAction", soapaction);
    connection.setRequestProperty("Content-Type", "Text/xml");
    String AuthorizationString = "Basic " + (username + ":" +  password).bytes.encodeBase64();
    connection.setRequestProperty("Authorization", authorizationString);
    OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
    wr.write(xml);
    wr.close();

    // Get the response
        String response;
        InputStream responseStream;
        try {
            responseStream = connection.getInputStream();
            success = 1;
        } catch( IOException e ) {
            success = 0;
            if( connection.getResponseCode() == 500 ) {
                responseStream = connection.getErrorStream();
            } else throw e;
        }

    response = responseStream.getText("utf-8");
    responseStream.close();
    return response;
}
2 REPLIES 2
itsmylife
New Contributor

Re: Modularize the soapui test suites: Groovy script in eclipse, create a jar file & call it int

When I add a main method to the above code I am getting another error. Please help me to sort out the best way to deal with this task.

 

Caught: groovy.lang.MissingMethodException: No signature of method: static com.qwertyqw.main() is applicable for argument types: ([Ljava.lang.String; ) values: [[]]
Possible solutions: main([Ljava.lang.String; ), wait(), wait(long), any(), find(), wait(long, int)
groovy.lang.MissingMethodException: No signature of method: static com.swsim.demo.CreateEnvelopeIndicium.main() is applicable for argument types: ([Ljava.lang.String; ) values: [[]]
Possible solutions: main([Ljava.lang.String; ), wait(), wait(long), any(), find(), wait(long, int)

Olga_T
Moderator

Re: Modularize the soapui test suites: Groovy script in eclipse, create a jar file & call it int

Hi @itsmylife, thanks for reaching out.

 

Community, has anyone faced a similar situation? Can anyone assist please? 

 


Olga Terentieva
SmartBear Assistant Community Manager

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors