jedizippy
16 years agoNew Contributor
Retrieving Response from Test Step using Java API
Hi,
We are using the java API to invoke WSDL test requests for our web services using the WSDLTestCaseRunner. When the test competes (or fails) we can print out the reason codes or messages but we wish to pick up for the example the web service responses. How can this be achieved ? The code we are using is shown below but we cant seem to figure out how to get the test case step responses so that we can print them to log4j so we can see what is happening when for example the web service call fails or we got soap faults etc, or its successful in which case it would be nice to see the SOAP response ?.
project = new WsdlProject(projectName);
testSuite = project.getTestSuiteByName(testSuiteName);
testCase = testSuite.getTestCaseByName(TEST_CASE_NAME_JUNIT);
runner = new WsdlTestCaseRunner(testCase, new StringToObjectMap());
runner.start(false);
List results = runner.getResults();
if (results != null && results.size() > 0) {
Iterator it = results.iterator();
while (it.hasNext()) {
TestStepResult thisResult = (TestStepResult) it.next();
String[] messages = thisResult.getMessages();
if (messages != null && messages.length > 0) {
for(String message : messages) {
logger.debug("SOAUP UI Message: " + message); }
}
Throwable error = thisResult.getError();
if (error != null) {
Logger.error("Reason Message: " + thisResult.getError());
}
}
}
We are using the java API to invoke WSDL test requests for our web services using the WSDLTestCaseRunner. When the test competes (or fails) we can print out the reason codes or messages but we wish to pick up for the example the web service responses. How can this be achieved ? The code we are using is shown below but we cant seem to figure out how to get the test case step responses so that we can print them to log4j so we can see what is happening when for example the web service call fails or we got soap faults etc, or its successful in which case it would be nice to see the SOAP response ?.
project = new WsdlProject(projectName);
testSuite = project.getTestSuiteByName(testSuiteName);
testCase = testSuite.getTestCaseByName(TEST_CASE_NAME_JUNIT);
runner = new WsdlTestCaseRunner(testCase, new StringToObjectMap());
runner.start(false);
List
if (results != null && results.size() > 0) {
Iterator it = results.iterator();
while (it.hasNext()) {
TestStepResult thisResult = (TestStepResult) it.next();
String[] messages = thisResult.getMessages();
if (messages != null && messages.length > 0) {
for(String message : messages) {
logger.debug("SOAUP UI Message: " + message); }
}
Throwable error = thisResult.getError();
if (error != null) {
Logger.error("Reason Message: " + thisResult.getError());
}
}
}