Skip to content

Instantly share code, notes, and snippets.

@yukihirai0505
Last active April 14, 2021 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukihirai0505/9d22ac98c5352b07cd2092357da7b982 to your computer and use it in GitHub Desktop.
Save yukihirai0505/9d22ac98c5352b07cd2092357da7b982 to your computer and use it in GitHub Desktop.
How to send a SOAP UI request from Java code
apply plugin: 'java'
...
dependencies {
testCompile "com.smartbear.soapui:soapui:5.4.0"
}
...
repositories {
maven {
url 'http://www.soapui.org/repository/maven2/'
artifactUrls 'http://repo1.maven.org/maven2'
}
mavenCentral()
}
...
package utils;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.model.iface.*;
public class SoapUIRequestSender {
private WsdlProject _project;
public SoapUIRequestSender() {
try {
_project = new WsdlProject("path-to/soapui-project.xml");
} catch (Exception e) {
e.printStackTrace();
}
}
public Response sendRequest(String requestName) throws Exception {
Interface soapUIInterface = _project.getInterfaceByName("Interface Name");
Operation operation = soapUIInterface.getOperationByName("Operation Name");
Request request = operation.getRequestByName("Request Name");
Submit submit = request.submit(new WsdlSubmitContext(request), false);
return submit.getResponse();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment