使用wsdl创建SOAPUI项目

2022-04-06 00:00:00 java soapui

我要使用WSDL创建一个SOAPUI项目。

这是我的代码:

 File projectFile =new File("Test/sampleURI-soapui-project");
 SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
 WsdlProject project = new WsdlProject("sampleURI");

 WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://192.168.18.171/sample/api/v2_soap/?wsdl");

 for(int j=0;j<wsdls.length;j++){
 WsdlInterface wsdl = wsdls[j];
 String soapVersion = wsdl.getSoapVersion().toString();
 int c = wsdl.getOperationCount();

 String reqContent="";
 String result="";

 for(int i=0;i<c;i++){
    WsdlOperation op = (WsdlOperation) wsdl.getOperationAt(i);
    String opName = op.getName();
    reqContent = op.createRequest(true);
    WsdlRequest req = op.addNewRequest("Req_"+soapVersion+"_"+opName);
    }
 }

我收到以下错误:

警告[SoapUI]缺少外部库的文件夹[D:lippseProgramskepler-workspaceTest.ext 线程"Main"中出现异常java.lang.NoSuchMethodError:org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Ljava/lang/ClassLoader;Ljava/lang/String;)Lorg/apache/xmlbeans/SchemaTypeSystem; 在com.eviware.soapui.config.SoapuiSettingsDocumentConfig.(Unknown源) 在com.eviware.soapui.config.SoapuiSettingsDocumentConfig$Factory.parse(Unknown源) 在com.eviware.soapui.DefaultSoapUICore.initSettings(DefaultSoapUICore.java:211) 在com.eviware.soapui.SwingSoapUICore.initSettings(SwingSoapUICore.java:118) 在com.eviware.soapui.DefaultSoapUICore.init(DefaultSoapUICore.java:142) 在com.eviware.soapui.StandaloneSoapUICore.(StandaloneSoapUICore.java:37) 在sampleSoap.main(sampleSoap.java:20)

遇到此问题需要哪个JAR文件?如果有任何帮助,我们将不胜感激。


解决方案

typeSystemForClassLoader方法是在xBean 2.0.0版本之后引入的,请使用更高版本(2.1.0)来解决此问题。比较javadoc共2个版本

<dependency>
    <groupId>xmlbeans</groupId>
    <artifactId>xbean</artifactId>
    <version>2.1.0</version>
</dependency>

相关文章