How to customize soapUI library to generate request amp; response from WSDL?(如何定制soapUI库以生成来自wsdl的请求和响应?)
本文介绍了如何定制soapUI库以生成来自wsdl的请求和响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个模块,它将采用wsdl
&;生成请求和响应文档。为此,我使用代码中提到的soapui
库Post
package com.bbog.soap;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
import com.eviware.soapui.model.iface.Operation;
public class WsdlAnalyzer {
public static void main(String[] args) throws Exception {
WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://localhost:7000/Solicitud?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));
}
}
}
因此,当我使用它来生成SOAP请求和响应时,一些东西正在后台运行(我可以在Net Beans中看到),即使它不在for循环中。请帮助我自定义soapUI库以调用适当方法来生成请求&;响应&;释放任何创建/初始化的资源。
推荐答案
这就是我处理请求和响应的方式
WsdlOperation wsdlOperation = (WsdlOperation) operation;
// create a new empty request for that operation
WsdlRequest request = wsdlOperation.addNewRequest("My request");
request.setTimeout("2000");
requestContent = wsdlOperation.createRequest(true);
request.setRequestContent(requestContent);
System.out.println("REQUEST: " + requestContent);
// submit the request
try {
WsdlSubmit submit = (WsdlSubmit) request.submit(new WsdlSubmitContext(request), false);
Status status = submit.getStatus(); //FINISHED OR ERROR
System.out.println("STATUS: " + status);
Response response = submit.getResponse();
System.out.println("RESPONSE: " + response.getContentAsString());
} catch (SubmitException ex) {
//Catch the exception
}
希望能有所帮助
这篇关于如何定制soapUI库以生成来自wsdl的请求和响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何定制soapUI库以生成来自wsdl的请求和响应?
基础教程推荐
猜你喜欢
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01