Forum Discussion
PaulDonny
12 years agoRegular Contributor
I should have posted a follow up here to explain that I had accomplished it. Here is the code I used:
(Again, this is in Java, not SoapUI itself. I am building something to build SoapUI project files). This snippet will essentially build a SoapUI request for the single operation currently.
WsdlProject project = new WsdlProject();
project.setName("Test");
WsdlInterface iface = WsdlInterfaceFactory.importWsdl(project, "MyWsdlPath", true)[0];
String host = "MyHostPath";
String endpoint = iface.getEndpoints()[0].replaceAll("http.*?//.*?/",host);
iface.changeEndpoint(iface.getEndpoints()[0],endpoint);
WsdlOperation operation = (WsdlOperation) iface.getOperationByName("OperationIamBuilding");
WsdlTestSuite TS = project.addNewTestSuite("Test");
TS.setName("Test");
TestStepConfig TStepC = WsdlTestRequestStepFactory.createConfig(operation, "Test");
WsdlTestCase TC = TS.addNewTestCase("Test");
WsdlTestStep TStep = TC.addTestStep(TStepC);
String rawRequest = TStep.getPropertyValue("Request");
TStep.setPropertyValue("Username", properties.get("username").trim());
TStep.setPropertyValue("Password", properties.get("password").trim());
NodeList nodes = XmlUtils.parseXml(operation.getRequestAt(0).getRequestContent()).getChildNodes();
String XML = XmlUtils.prettyPrintXml(XmlUtils.createXmlObject(nodes.item(0).getParentNode()));
XML = XML.replaceAll( "(?s)<!--.*?-->","");
//Data parsing would go here.
TStep.setPropertyValue("Request", XML);
project.saveAs("Test.xml");
(Again, this is in Java, not SoapUI itself. I am building something to build SoapUI project files). This snippet will essentially build a SoapUI request for the single operation currently.