I’ve created a small scala-script to extract messages from SOAPUI. Writing this was surprisingly easy, and certainly faster and more pleasant then processing the SOAPUI manually.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml._ | |
import java.io._ | |
/** | |
* Small script to extract the request-xml-messages from a soapui project | |
*/ | |
object SoapUIExtractor extends App { | |
def writeTestStep(teststep:Node) { | |
val requestContent = (teststep \ "config" \ "restRequest" \ "request").head.child(0).text | |
val testCaseName = (teststep \ "@name").head.text | |
val filename = testCaseName+".xml" | |
println(filename) | |
val writer = new PrintWriter(new File( filename )) | |
writer.write(requestContent) | |
writer.close() | |
println(requestContent) | |
} | |
val soapUI = XML.loadFile("my_soapui-project.xml") | |
//extract all test cases and write the request-xml that's contained in each test-case | |
(soapUI \\ "soapui-project" \ "testSuite" \ "testCase" \ "testStep" ).foreach ( r => writeTestStep(r) ) | |
} |