Forum Discussion

DKorkchi's avatar
DKorkchi
New Contributor
15 years ago

[Res] SoapUIPro SOAP Response schema validation using API

I am running soapui project files through the API, like so:

WsdlProjectPro project
= (WsdlProjectPro) ProjectFactoryRegistry.getProjectFactory(WsdlProjectProFactory.WSDL_TYPE)
.createNew(filename);

for(int i=0;i<project.getTestSuiteCount();++i)
{
WsdlTestSuitePro testSuite = (WsdlTestSuitePro) project.getTestSuiteAt(i);
if(!testSuite.isDisabled())
{
runTestSuite(testSuite);
}
}

Everything runs okay, except all soap responses trigger a schema validation error, hence the error message:

Step Status,ReportTags,"TestStep [ReportTags] result status is FAILED; [[SOAP Response] org/xmlsoap/schemas/soap/envelope/EnvelopeDocument, [Schema Compliance] org/xmlsoap/schemas/soap/envelope/EnvelopeDocument] [discarded]"

I only get errors for soap requests. Requests like HTTP or steps like Scripts work fine and status says OK.

I have tested the project in the SoapUIPro gui, and everything runs fine, all soap requests return with status OK. I have even taken the responses from my program and pasted them into the SoapUIPro gui and validated them, and they validate.

I am also running the above code from inside a .aar deployed to Apache Axis2.

3 Replies

  • Hi!

    this sounds like a class-loading error to me.. how are you loading the soapUI dependencies in this scenario?

    regards,

    /Ole
    eviware.com
  • DKorkchi's avatar
    DKorkchi
    New Contributor
    They are included in an uber-jar (created with Maven shade plugin). Then the resulting jar is "deployed" through a class in the .aar package by using the system classloader. Here's the code snippet:

    public static Class<?> loadClassFromJar(String path, String className)
    {
    Class<?> c = null;

    try {

    URL url = new URL("jar:file://" + path + "!/");
    URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    URL[] urls = sysLoader.getURLs();
    for (int i = 0; i < urls.length; i++) {
    if (urls.toString().equalsIgnoreCase(url.toString())) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, "URL " + url + " is already in the CLASSPATH");
    System.out.println();
    }
    }
    Class sysclass = URLClassLoader.class;
    Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
    method.setAccessible(true);
    Object invoke = method.invoke(sysLoader, new Object[]{url});
    ClassLoader loader = URLClassLoader.newInstance(new URL[]{url}, JarClassLoader.class.getClassLoader());
    if(className != null)
    c = Class.forName(className, true, loader);

    } catch (ClassNotFoundException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (NoSuchMethodException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (SecurityException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (IllegalAccessException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (IllegalArgumentException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (InvocationTargetException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    } catch (MalformedURLException ex) {
    Logger.getLogger(JarClassLoader.class.getName()).log(Level.FATAL, null, ex);
    }

    return c;
    }

    I don't receive any ClassLoader errors though.
  • DKorkchi's avatar
    DKorkchi
    New Contributor
    Bingo. Was a dependency issue. I neglected to include the soap-xmlbeans jar.