如何创建SOAP UI项目并在Java中运行请求 [英] how to create a SOAP UI project and run requests to it in Java
问题描述
我想创建一个将执行以下操作的Java类
1.使用wsdl加载/创建一个SOAPUI项目。
2.运行对该操作的请求wsdl。
I want to create a Java class that will do the following
1. load/create a SOAPUI project using a wsdl.
2. run requests to the operations in that wsdl.
这是我的SoapJavaTest.java文件(尽管这还不完整,它只是在SOAP UI中注册项目并打印其中包含的操作)
This is my SoapJavaTest.java file(though this is not complete, it is just registering a project in SOAP UI and printing the operations contained in it)
public class SoapJavaTest{
public static void main(String args[]) throws Exception{
String projectFile ="SoapUIJavaTest\\SoapUIProjects\\soapui-project1.xml";
WsdlProject project = new WsdlProject (projectFile);
//WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://metalmaker.net/metalmaker.asmx?WSDL");
WsdlInterface wsdl = wsdls[0];
for (Operation operation : wsdl.getOperationList()){
WsdlOperation op = (WsdlOperation) operation;
System.out.println("OP:"+op.getName());System.out.println(op.createRequest(true));
System.out.println("Response:");System.out.println(op.createResponse(true));
}
}
}
我是得到以下错误 - '的NoSuchMethodError:org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Ljava /郎/类加载器; Ljava /郎/字符串;)Lorg /阿帕奇/的xmlbeans / SchemaTypeSystem;'
I am getting the following error - 'NoSuchMethodError: org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Ljava/lang/ClassLoader;Ljava/lang/String;)Lorg/apache/xmlbeans/SchemaTypeSystem;'.
我已经包含了以下jar文件
1. commons-cli-1.2
2. commons-httpclient-3.1
3. log4j
4. soapui-3.6-beta2
5. soapui-xmlbeans-2.0.2
6. wsdl-xmlbeans-1.1
7 .xbean-1.0.3
8. xmlbeans-xmlpublic-2.2.0
9. XmlSchema-1.0.3
I have included the following jar files
1. commons-cli-1.2
2. commons-httpclient-3.1
3. log4j
4. soapui-3.6-beta2
5. soapui-xmlbeans-2.0.2
6. wsdl-xmlbeans-1.1
7. xbean-1.0.3
8. xmlbeans-xmlpublic-2.2.0
9. XmlSchema-1.0.3
我错过了哪个jar文件,或者我使用的是错误的类?任何帮助,将不胜感激。
What jar file am I missing or is it the wrong classes that I am using? Any help would be appreciated.
推荐答案
最后我能够解决这个问题。我正在创建一个SoapUI项目,保存它并通过代码发送所有请求。请参阅链接此处了解完整详情。谢谢。
Finally I am able to solve this. I am creating a SoapUI project, saving it and sending requests all via code. Please refer to link here for complete details. Thanks.
这篇关于如何创建SOAP UI项目并在Java中运行请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!