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

*爱你&永不变心* 提交于 2019-12-24 10:03:07

问题


I am developing a module which will take a wsdl & generates request & response documents. For this I am using soapui library as mentioned in this code 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));
    }
}
}

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. Please help me in customizing that soapUI library to call the appropriate method to generate request & response & release any created/initialized resources.


回答1:


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



来源:https://stackoverflow.com/questions/14731441/how-to-customize-soapui-library-to-generate-request-response-from-wsdl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!