ContributionsMost RecentMost LikesSolutionsRe: TestStep is listed under WsdlTestCase on debug, however cannot be saved to project file at .saveIn() Hi, It works, really appreciated. Thank you very much, JHunt! Re: TestStep is listed under WsdlTestCase on debug, however cannot be saved to project file at .saveIn() So, apart from the question, haven't seen such implementation in Java, in elsewhere for the REST services. If there is really no-one tried this or just no one have the idea, I'd replicate this to stackoverflow. I've added further configuration and enriched the RestMethodConfig auth, originalUrl etc. If anyone have saved a REST project.xml before, let me know please. TestStep is listed under WsdlTestCase on debug, however cannot be saved to project file at .saveIn() Hi all, I've recently saved a wsdl project without any hassle, and now would like to do the similar with REST endpoints. I've come up with a piece of code that can actually working up to a point; where it seems RestTestRequestStep is hold inside the RestRequest. (observed on debug.) wsdlTestCase.insertTestStep(testStepConfigx, -1); // it does put the test step under the test case in debug. wsdlTestCase.getTestStepList().get(0) on debug returns a RestTestRequestStep with below config. it has such config: <xml-fragment service="http://jsonplaceholder.typicode.com" resourcePath="/posts" methodName="Posts 1" xsi:type="con:RestRequestStep" xmlns:con="http://eviware.com/soapui/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <con:restRequest name="Step" id="a66d91c1-0189-4a08-a9bb-b1c25d22c559" mediaType="application/json"> <con:settings/> <con:endpoint>http://jsonplaceholder.typicode.com</con:endpoint> <con:parameters/> </con:restRequest> </xml-fragment> My question is how do I persist this request step as well, into the project xml file? Currently saved file does not contain this part and once imported to SOAPUI, I cannot see any test steps or requests, below test case of the corresponding test suite. In general, we supply WsdlTestCase a TestStepConfig, and this config supposed to be in some specific form to be persisted in a file? I haven't done such thing for wsdl projects. My code is as follows: //ApplicationRunner.java public class ApplicationRunner { public static void main(String[] args) throws XmlException, IOException, SoapUIException, RestRequestStepFactory.ItemDeletedException { String url = "http://jsonplaceholder.typicode.com/posts"; String fileName = "project.xml"; File projectFile = new File("fileDir/" + fileName); RestConfiguration restConfiguration = new RestConfiguration(RestRequestConfig.Factory.newInstance(), RestResourceConfig.Factory.newInstance(), RestServiceConfig.Factory.newInstance(), TestStepConfig.Factory.newInstance(), TestCaseConfig.Factory.newInstance(), RestMethodConfig.Factory.newInstance()); TestCaseConfig testCaseConfig = restConfiguration.getTestCaseConfig(); WsdlProject wsdlProject = new WsdlProject(); wsdlProject.setName("restProject"); WsdlTestSuite wsdlTestSuite = wsdlProject.addNewTestSuite("Suite"); wsdlTestSuite.addNewTestCase("Case"); WsdlTestCase wsdlTestCase = new WsdlTestCase(wsdlTestSuite, testCaseConfig, false); RestServiceBuilder serviceBuilder = new RestServiceBuilder(); serviceBuilder.createRestService(wsdlProject, url); RestService restService = (RestService) wsdlProject.getInterfaceList().get(0); RestResource restResource = restService.getOperationAt(0); RestRequest requestx = restResource.getRequestAt( 0 ); TestStepConfig testStepConfigx = RestRequestStepFactory.createConfig(requestx, "Step"); wsdlTestCase.insertTestStep(testStepConfigx, -1); /* I can even set requestContent at runtime. TestStep testStep = wsdlTestCase.insertTestStep(testStepConfigx, -1); // insertTestStep can be seen as of typ RestTestRequestStep inside wsdlTestCase.getTestStepList() RestTestRequestStep restTestRequestStep = (RestTestRequestStep) testStep; restTestRequestStep.getTestRequest().setRequestContent("requestContentHere") */ // attached the outputted xml project file. wsdlProject.saveIn(projectFile); } } //RestConfiguration.java public class RestConfiguration { RestRequestConfig restRequestConfig; RestResourceConfig restResourceConfig; RestServiceConfig restServiceConfig; TestStepConfig testStepConfig; TestCaseConfig testCaseConfig; RestMethodConfig restMethodConfig; public RestConfiguration(RestRequestConfig restRequestConfig, RestResourceConfig restResourceConfig, RestServiceConfig restServiceConfig, TestStepConfig testStepConfig, TestCaseConfig testCaseConfig, RestMethodConfig restMethodConfig){ this.restRequestConfig = restRequestConfig; this.restResourceConfig = restResourceConfig; this.restServiceConfig = restServiceConfig; this.testStepConfig = testStepConfig; this.testCaseConfig = testCaseConfig; this.restMethodConfig = restMethodConfig; } public RestRequestConfig getRestRequestConfig() { return restRequestConfig; } public RestResourceConfig getRestResourceConfig() { return restResourceConfig; } public RestServiceConfig getRestServiceConfig() { return restServiceConfig; } public TestStepConfig getTestStepConfig() { return testStepConfig; } public TestCaseConfig getTestCaseConfig() { return testCaseConfig; } public RestMethodConfig getRestMethodConfig() { return restMethodConfig; } } SolvedRe: How to create REST project using Groovy script? Hi Rupert, Is it also possible saving the project to an output file like in wsdl project.saveIn()? Problem with saving/creating REST TestRequests as project (in Java) Hi, Recently I've successfully developed a method that uses wsdl endpoint and saves the SOAPUI project file. Our purpose is to create these project documents for the endpoints with custom request contents,then run regularly on some remote machine that have SOAPUI installed. However, for the REST part, I've done many things but could not make it work to add test step(s) to the test case. I am not sure if followed the right practice, yet I can see that there is a testStep under the testRequestList. My code is as follows (also attaching one of the failure projects): --- TestCaseConfig testCaseConfig = restConfiguration.getTestCaseConfig(); WsdlProject wsdlProject = new WsdlProject(); wsdlProject.setName("restProject"); RestServiceBuilder serviceBuilder = new RestServiceBuilder(); serviceBuilder.createRestService(wsdlProject, url); WsdlTestSuite wsdlTestSuite = wsdlProject.addNewTestSuite("Suite"); WsdlTestCase wsdlTestCase = new WsdlTestCase(wsdlTestSuite, testCaseConfig, false); wsdlTestSuite.addNewTestCase("Case"); RestService restService = (RestService) wsdlProject.getInterfaceList().get(0); RestResource restResource = restService.getOperationAt(0); RestRequest requestx = restResource.getRequestAt( 0 ); TestStepConfig testStepConfigx = RestRequestStepFactory.createConfig(requestx, "Step"); wsdlTestCase.addTestStep(testStepConfigx); wsdlTestCase.insertTestStep(testStepConfigx, -1); wsdlProject.saveIn(projectFile);