Forum Discussion

Neustar's avatar
Neustar
Occasional Contributor
13 years ago

SOAP Response assertion fails when invoked from Java

Hello

I have a SOAP UI test with one step that has a "SOAP Response" assertion in addition to some other assertions. When this test is run from SOAP UI, the test passes. When the same test is called from Java, runner.getStatus reports "FAILED". After some debugging, I see that all assertions pass except the "SOAP Response" assertion. Here is the response from the debug logs that fails the "SOAP Response" assertion when invoked from Java.

10:27:42.820 [main] DEBUG httpclient.wire.content - << "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><v01:createPrimaryZoneResponse xmlns:v01='http://webservice.api.ultra.neustar.com/v01/'><result>Successful</result></v01:createPrimaryZoneResponse></env:Body></env:Envelope>"

Below is the response from the SOAP UI tool where the "SOAP Response" assertion passes successfully

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<v01:createPrimaryZoneResponse xmlns:v01="http://webservice.api.ultra.neustar.com/v01/">
<result>Successful</result>
</v01:createPrimaryZoneResponse>
</env:Body>
</env:Envelope

How can I get this resolved and get my "SOAP Response" assertion to pass when the SOAP UI test is called from Java?
  • Neustar's avatar
    Neustar
    Occasional Contributor
    I am directly invoking the SOAP UI testcase and the testcase fails. My further debugging indicated that the testcase failed due to an assertion failing. The assertion as I stated earlier fails only when the testcase is invoked from java and not when the testcase is invoked through soap ui. Below is how I invoke the testcase from java and get results back.

    project = new WsdlProject(
    "testdata/soapui-project.xml");

    testSuite = project.getTestSuiteByName(testSuiteName);
    testCase = testSuite.getTestCaseByName(testCaseName);

    testSuite.setPropertyValue("accountid",
    TestContext.context.get("soapAccountId").toString());

    for (Map.Entry<String,String> entry : map.entrySet()) {
    testSuite.setPropertyValue(entry.getKey(), entry
    .getValue());
    }
    for (TestStep testStep : testCase.getTestStepList()) {
    if (testStep instanceof WsdlTestRequestStep) {
    ((WsdlTestRequestStep) testStep).getTestRequest().setUsername(
    TestContext.context.get("soapUsername").toString());
    ((WsdlTestRequestStep) testStep).getTestRequest().setPassword(
    TestContext.context.get("soapPassword").toString());
    ((WsdlTestRequestStep) testStep).getTestRequest().setEndpoint(
    TestContext.context.get("soapUrl").toString());
    }
    }

    runner = testCase.run(null, false);

    if (runner.getStatus() == com.eviware.soapui.model.testsuite.TestRunner.Status
    .valueOf("FINISHED")) {
    return true;
    } else {
    logger.info("Test not passed because {} ",
    new Object[] { runner.getReason() });
    System.out.println("Reason for failure is " + runner.getReason());
    return false;
    }
  • Hi,

    This could actually be classloader/classpath related - do you have all soapUI\lib jars in your classpath? Do you have any colliding versions of XmlBeans or Xerces there as well!?

    regards,

    /Ole
    SmartBear Software