ContributionsMost RecentMost LikesSolutionsWorking with GROOVY and SCRIPTOM - to use ( Explorer, Excel,.... )Hi here is the code what I found on internet, and I dont know why it brings ERROR : java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.InvokerHelper.getInstance()Lorg/codehaus/groovy/runtime/Invoker; --> this code shout OPEN explorer and load url provided in code. I have added SCRIPTOM 1.2 files into BIN, and LIB folders of soapUI and restarted it. //----------------------------------------------------------------- import org.codehaus.groovy.scriptom.ActiveXProxy // instantiate Internet Explorer def explorer = new ActiveXProxy("InternetExplorer.Application") // set its properties explorer.Visible = true; explorer.AddressBar = true; // navigate to a site by calling the Navigate() method explorer.Navigate("http://glaforge.free.fr/weblog"); // ----------------------------------------------------------------Re: HOW TO SEND REST or SOAP request by JAVA CODEmy Account number 440754308 / 0900Re: HOW TO SEND REST or SOAP request by JAVA CODEimport java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import com.eviware.soapui.impl.wsdl.*; import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase; import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext; import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep; import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer; import com.eviware.soapui.impl.wsdl.panels.support.MockTestRunContext; import com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner; import com.eviware.soapui.model.testsuite.TestStepResult; public class FirstClass { // create new project static WsdlProject project = null; static WsdlTestSuite testSuite = null; static WsdlTestCase testCase = null; static WsdlTestStep testStep = null; static WsdlTestRunContext context = null; static String endPoint = null; static String path = null; static String parameters = null; static String requestURL = null; // M A I N public static void main(String[] args) { // SET PROXY //setProxySettings(); // LOAD PROJECT DATA (project, suite, case, step) loadProject_step("C:/SVN_Repozitory/ncs/cds/flight stats/03.implementation/Flight-stats-soapui-project.xml", "Flights", "FS_IATA2_flightNumber", "FS_IATA2_flightNumber" ); // SET UP REQUEST setUpRequestURL(); // PREPARATION 1: Look for previous groovy scripts testSteps, to run them first (should set the data first) //runStartUpScripts(); // execute OUR special testStep executeProject_step(); } // F U N C T I O N S: public static void loadProject_step(String projectPath, String testSuiteName, String testCaseName, String testStepName) { // create new project project = new WsdlProject( projectPath, "" ); testSuite = project.getTestSuiteByName(testSuiteName); testCase = testSuite.getTestCaseByName(testCaseName); testStep = testCase.getTestStepByName(testStepName); context = new WsdlTestRunContext( testStep ); endPoint = expandProperties(context, testStep.getPropertyValue("endpoint")); path = expandProperties(context, testStep.getPropertyValue("path")); } public static void setUpRequestURL() { System.out.println("\n=================================="); parameters = "?"; for(int i=0; i< testStep.getPropertyCount(); i++ ) { if( testStep.getPropertyAt(i).getValue() != null && testStep.getPropertyAt(i).getValue().compareTo("") != 0 &&testStep.getPropertyAt(i).getName().compareTo("Endpoint")!=0 && testStep.getPropertyAt(i).getName().compareTo("Domain")!=0 && testStep.getPropertyAt(i).getName().compareTo("ResponseAsXml")!=0 && testStep.getPropertyAt(i).getName().compareTo("Password")!=0 && testStep.getPropertyAt(i).getName().compareTo("Path")!=0 && testStep.getPropertyAt(i).getName().compareTo("Username")!=0 && testStep.getPropertyAt(i).getName().compareTo("Response")!=0) { System.out.println(testStep.getPropertyAt(i).getName() + " = " + expandProperties(context, testStep.getPropertyAt(i).getValue()) ); if(parameters.length()<2) parameters = parameters + testStep.getPropertyAt(i).getName() + "=" + expandProperties(context, testStep.getPropertyAt(i).getValue()); else parameters = parameters + "&" + testStep.getPropertyAt(i).getName() + "=" + expandProperties(context, testStep.getPropertyAt(i).getValue()); }//if }//for System.out.println("=================================="); requestURL = endPoint + path + parameters; System.out.println("requestURL : " + requestURL); } public static String expandProperties(WsdlTestRunContext context, String request) { // use everything what found in ( ... ) ----> context.expand( ... ) int index = request.indexOf("${"); while(index >= 0) { int endIndex = request.indexOf("}") + 1; String foundString = request.substring(index, endIndex); String toReplaceString = context.expand( foundString ); // extract VALUE using SoapUI method expand. request = request.replaceFirst("(\\$\\{.+\\})", toReplaceString); index = request.indexOf("${"); } return request; } public static void setProxySettings() { // PROXY SETTINGS System.getProperties().put("http.proxyHost", "172.168.30.36"); System.getProperties().put("http.proxyPort", "8080"); //System.getProperties().put("http.proxyUser", "someUserName"); //System.getProperties().put("http.proxyPassword", "somePassword"); } public static void runStartUpScripts() { try { System.out.print("\nRuning Project's Load script ..."); if( project.getAfterLoadScript()!=null && project.getAfterLoadScript().replaceAll(" ", "").length() > 2 ) { project.runAfterLoadScript(); System.out.print("DONE"); } else System.out.print("empty"); System.out.print("\nRuning Project's Save script ..."); if( project.getBeforeSaveScript()!=null && project.getBeforeSaveScript().replaceAll(" ", "").length() > 2 ) { project.runBeforeSaveScript(); System.out.println("DONE"); } else System.out.println("empty"); System.out.print("\nRuning TestSuite's Setup script ..."); if( testSuite.getSetupScript()!=null && testSuite.getSetupScript().replaceAll(" ", "").length() > 2 ) { testSuite.runSetupScript(context); System.out.print("DONE"); } else System.out.print("empty"); System.out.print("\nRuning TestSuite's TearDown script ..."); if( testSuite.getTearDownScript()!=null && testSuite.getTearDownScript().replaceAll(" ", "").length() > 2 ) { testSuite.runTearDownScript(context); System.out.println("DONE"); } else System.out.println("empty"); System.out.print("\nRuning TestCases's Setup script ..."); if( testCase.getSetupScript()!=null && testCase.getSetupScript().replaceAll(" ", "").length() > 2 ) { testCase.runSetupScript(context , context.getTestRunner()); System.out.print("DONE"); } else System.out.print("empty"); System.out.print("\nRuning TestCases's TearDown script ..."); if( testCase.getTearDownScript()!=null && testCase.getTearDownScript().replaceAll(" ", "").length() > 2 ) { testCase.runTearDownScript(context , context.getTestRunner()); System.out.println("DONE"); } else System.out.println("empty"); } catch(Exception e) { System.out.println(e.getMessage()); } }// runStarUpScripts() public static void runSpecialTestStepsFirst() { // Check for special steps to run them first if needed TestStepResult ts_result = null; if( testCase.getIndexOfTestStep(testStep) > 0) { boolean transfer_found = false; for(int i=0; i if(testCase.getTestStepAt(i).getModelItem().toString().indexOf("PropertyTransfersTestStep") >= 0 ) { transfer_found = true; System.out.println("\nFound a Transfer Property - step as first."); PropertyTransfer my = new PropertyTransfer(testCase.getTestStepAt(i)); System.out.println(testCase.getTestStepAt(i).getName()); System.out.println("--------- SOURCE---------->> " + my.getSourceStepName()); System.out.println("--------- TARGET---------->> " + my.getTargetStepName()); } } for(int i=0; i if(testCase.getTestStepAt(i).getModelItem().toString().indexOf("WsdlGroovyScriptTestStep") >= 0 || transfer_found == true) { // run this groovy script MockTestRunner mockTR = new MockTestRunner(testCase); MockTestRunContext mockTRContext = new MockTestRunContext(mockTR, testStep); System.out.println("\nRunning ... ------------ >>> " + testCase.getTestStepAt(i).getName()); ts_result = testCase.getTestStepAt(i).run(mockTR, mockTRContext); } } } }// runSpecialTestStepsFirst() public static void executeProject_step() { try { URL targetURL = new URL(requestURL); HttpURLConnection conn = (HttpURLConnection) targetURL.openConnection(); conn.setAllowUserInteraction(true); conn.setConnectTimeout(15000); // 15 sec. connection timeout conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-type", "text/html; charset=" + "UTF-8"); long timeTaken = System.currentTimeMillis(); conn.connect(); // just sending the request. timeTaken = System.currentTimeMillis() - timeTaken; System.out.println("The response >>> " + conn.getResponseMessage() + " , timeTaken: " + timeTaken + " ms"); System.out.println("\n RESPONSE :"); String str; InputStream inputstream = null; inputstream = conn.getInputStream(); int length = (int) conn.getContentLength(); if (length != -1) { byte incomingData[] = new byte[length]; inputstream.read(incomingData); str = new String(incomingData); } else { ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); int ch = 0; while ((ch = inputstream.read()) != -1) { bytestream.write(ch); } str = new String(bytestream.toByteArray()); bytestream.close(); } System.out.println(str); conn.disconnect(); // we don't like to wait for response } catch (Exception e) { } }// executeProject_step() }HOW TO SEND REST or SOAP request by JAVA CODEHi all, I have already known how to SEND SOAP request by using java (Eclipse). Now I need to know how to do the SAME but in REST service. Here is example for sending SOAP request: ========================================================================= SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFactory.createConnection(); MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); StreamSource new_Request = new StreamSource( new ByteArrayInputStream(request.getBytes()) ); soapPart.setContent( new_Request ); message.saveChanges(); SOAPMessage reply = connection.call(message, endPoint); // ..handle with reply connection.close(); ========================================================================= If someone can paste here similar EXAMPLE how to send request but by REST service. Please, and Thank You All. !!!Re: Re: call java method from groovyHi, as I know, you should put your JAR file to soapUI / bin / ext directory, then restart soapUI. Must restart Good luck.Unknown ERROR with RUNNING "Groovy Script" type testStepHello all, Can someone please explain me what is wrong with method : testStep.run ( testRunner, context ); That "run" method makes me trouble all f.. day. I wrote it foolowing way and ALWAYS brings me ONE ERROR, but the code works and the groovy step has been executed properly. Everythings has gone find, but still that error appears : --------------------------------------- Error: 14:18:55,328 ERROR [SoapUI] An error occured [java.lang.NullPointerException], see error log for details java.lang.NullPointerException at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:156) at FirstClass.main(FirstClass.java:129) ---------------------------------------------------------- My Code : WsdlProject project = new WsdlProject( "C:/......./soapui-project.xml", "" ); WsdlTestSuite testSuite = project.getTestSuiteByName("1 - Get_Categories"); WsdlTestCase testCase = testSuite.getTestCaseByName("1.1.1 - GetCategories_All"); WsdlTestStep testStep = testCase.getTestStepByName("GetCategories_All"); WsdlTestRunContext context = new WsdlTestRunContext( testStep ); for(int i=0; i if(testCase.getTestStepAt(i).getModelItem().toString().indexOf("WsdlGroovyScriptTestStep") >= 0 ) { System.out.println("Found a Groovy Script before this step."); // run this groovy script WsdlTestRunContext i_context = new WsdlTestRunContext( testCase.getTestStepAt(i) ); testCase.getTestStepAt(i).run(i_context.getTestRunner(), i_context); } }HOW TO LOAD project Properties like PROXY settings and ... with JAVA I use SAAJ technology to send extracted request from existing soapUI PROJECT and obtain response. It works perfect, but I realize, that should be problem when Proxy will be needed. Can you help me how to LOAD project settings (special proxy variables and port) by using SoapUI classes, which I know? Here is small extract where I need to put this proxy changes: //Send the message and get a reply System.out.print("\nSENDING Soap Request ... "); String destination = "http://ncs-fcs-apt-b.map24.local:42101/ncs-fcs-web/ncs/services....."; System.out.print("\nWAITING for Response ... "); SOAPMessage reply = connection.call(message, destination); System.out.print("OK\n");Re: HOW TO load soapUI PROJECT (xml) with java code in ECLIPSEI just included whole LIB folder of soapUI install folder to JAVA BUILDPath libraries, and now it works great. Sorry, but I have several others libraries in that LIB folder which made troubles and I had to delete them.HOW TO load soapUI PROJECT (xml) with java code in ECLIPSEHi all, I want to use soapUI classes, libraries, jars to load soapUI project and extract informations from it in Eclipse using normal JAVA language. I am trying to do something like : import com.eviware.soapui.impl.wsdl.*; public class FirstClass { public static void main(String[] args) { System.out.println("Hello Margit"); // create new project WsdlProject project = new wsdlProject ( "C:/EventSearch-soapui-project.xml", "" ); } } I dont know how to do this, becouse this code brings me several errors, but the project in Eclipse knows all JARS of the soapUI install folder. Can someone paste here simple code of loading existing soapUI project (I dont know maybe wrong function is used , maybe openProject(...),... I dont know ) Error: Cau Margit Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Ljava/lang/ClassLoader;Ljava/lang/String;)Lorg/apache/xmlbeans/SchemaTypeSystem; at com.eviware.soapui.config.SoapuiSettingsDocumentConfig. Re: HOW TO REMOVE test PROPERTIES via groovy scriptThank you. My fault was, that I tried to put the Object of property to remove function. so correct way : testCase.removeProperty( property_name ); thank you .