简体   繁体   English

如何自定义soapUI库以从WSDL生成请求和响应?

[英]How to customize soapUI library to generate request & response from WSDL?

I am developing a module which will take a wsdl & generates request & response documents. 我正在开发一个模块,该模块将使用wsdl并生成请求和响应文档。 For this I am using soapui library as mentioned in this code Post 为此,我现在用soapui库本规范中提到帖子

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));
    }
}
}

So when i use it to generate the soap request & response, something is running in background (which I can see in net beans) even it is out of for loop. 因此,当我使用它来生成肥皂请求和响应时,即使它不在for循环中,某些东西也在后台运行(我可以在net bean中看到)。 Please help me in customizing that soapUI library to call the appropriate method to generate request & response & release any created/initialized resources. 请帮助我自定义soapUI库,以调用适当的方法来生成请求和响应,并释放所有创建/初始化的资源。

This is how I handle Request and Responses 这就是我处理请求和响应的方式

   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
     }

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM