So I haven't really been able to find a decent way to do this. I am using the following methods for it if anyone else is interested in it.
public static void main(String[] args) throws Exception {
WsdlProject project = buildProject();
buildTestCases(project);
for (Interface iface:project.getInterfaceList()) {
for (Operation op:iface.getOperationList()) {
for (Request req:op.getRequestList()) {
Document doc = loadXMLFromString(req.getRequestContent());
//This is where the document parsing would be done
System.out.println(doc.getFirstChild());
}
}
}
//project.saveAs("Test.xml");
System.exit(0);
}
build project just builds the project, scans my WSDL directory and uses WsdlInterfaceFactory.importWsdl to import them.
private static WsdlProject buildProject() throws Exception {
File WSDLDir = new File(new File("").getAbsolutePath() + "\\Data\\WSDLs\\");
WsdlProject project = new WsdlProject();
project.setName("This is a new project");
WsdlInterface iface = null;
for (File wsdl : WSDLDir.listFiles()) {
iface = WsdlInterfaceFactory.importWsdl(project, wsdl.toString(), true)[0];
}
return project;
}
buildTestCases builds the testSuite TestCase and Test Steps and adds one step for each operation from the WSDL
private static void buildTestCases(WsdlProject project) {
WsdlTestSuite TS = project.addNewTestSuite("Test");
WsdlTestCase TC = TS.addNewTestCase("Test");
TS.setName("Test");
for (Interface inface : project.getInterfaceList()) {
for (Operation op : inface.getAllOperations()) {
TestStepConfig TStepC = WsdlTestRequestStepFactory.createConfig((WsdlOperation) op, op.getName());
TC.addTestStep(TStepC);
}
}
}
And loadXMLFromString sets the xml to a ByteArrayInputStream to be parsed by the DocumentBuilderFactory to give me a Document that can be used by w3c.dom
private static Document loadXMLFromString(String xml) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(xml.getBytes()));
}