Priyabrata Hota
Priyabrata Hota

Reputation: 151

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.

Upvotes: 4

Views: 11571

Answers (4)

albciff
albciff

Reputation: 18517

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,

Upvotes: 4

Dante
Dante

Reputation: 11

Another option is:

  1. Create a soapui project with one request
  2. Open the soapui-project XML file
  3. Search for con:call part
  4. Duplicate it and replace the con:request with your own XML request
  5. Save and reload the project in soapui

Upvotes: 1

Robert Strauch
Robert Strauch

Reputation: 12906

Or select "Load from..." when opening the context menu in the request view.

Upvotes: 1

Catchwa
Catchwa

Reputation: 5855

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

Upvotes: 1

Related Questions