Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import existing SOAP request messages to SoapUI?

I have a bunch of SOAP request messages in XML format. Is there a way to import them to a SoapUI project?

I want to import them and add as "Test Request" Test Step to an existing Test Case.

like image 227
Priyabrata Hota Avatar asked Aug 31 '25 03:08

Priyabrata Hota


2 Answers

An easy and more automatic way to do so is using a groovy script to automatically create the testStep request from a directory where you have you xml request files:

  1. Create a TestCase manually.
  2. Add an empty TestStep request which we will use as a template to create the other requests.
  3. Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps.

Your SOAPUI before groovy code execution looks like:

enter image description here

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())
}

Hope this helps,

like image 97
albciff Avatar answered Sep 02 '25 15:09

albciff


Copy/paste each into a new request, then right click on each request and add them to your test case.

like image 35
Catchwa Avatar answered Sep 02 '25 15:09

Catchwa