How to import existing SOAP request messages to So

2019-05-14 03:49发布

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.

4条回答
萌系小妹纸
2楼-- · 2019-05-14 04:12

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

查看更多
在下西门庆
3楼-- · 2019-05-14 04:13

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
查看更多
Root(大扎)
4楼-- · 2019-05-14 04:18

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

查看更多
小情绪 Triste *
5楼-- · 2019-05-14 04:19

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,

查看更多
登录 后发表回答