Skip to content

Instantly share code, notes, and snippets.

@yukihirai0505

yukihirai0505/Sample.java

Last active Apr 14, 2021
Embed
What would you like to do?
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