How do I import an existing soap request message into soapUI?
•
Java
I have a bunch of soap request messages in XML format Is there any way to import them into the soapUI project?
I want to import them and add the "test request" test step to the existing test case
Solution
A simple and more automatic way is to use groovy scripts to automatically create teststep requests from directories where you have XML request files:
>Create testcase manually. > Add an empty teststep request, which we use as a template to create other requests. > Add a groovy teststep that imports all files using the following code and executes it to create teststeps
The soapUI before groovy code execution is as follows:
And the necessary groovy Code:
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import groovy.io.FileType
// get the current testCase to add testSteps later
def tc = testRunner.testCase
// get the testStep as template to create the other requests
def tstemplate = tc.getTestStepByName("TestRequest template")
// create the factory to create testSteps
def testStepFactory = new WsdlTestRequestStepFactory()
def requestDir = new File("/your_xml_request_directory/")
// for each xml file in the directory
requestDir.eachFileRecurse (FileType.FILES) { file ->
def newTestStepName = file.getName()
// create the config
def testStepConfig = testStepFactory.createConfig( tstemplate.getOperation(),newTestStepName )
// add the new testStep to current testCase
def newTestStep = tc.insertTestStep( testStepConfig,-1 )
// set the request which just create with the file content
newTestStep.getTestRequest().setRequestContent(file.getText())
}
I hope it helps,
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
