Last active
April 14, 2021 04:37
-
-
Save yukihirai0505/9d22ac98c5352b07cd2092357da7b982 to your computer and use it in GitHub Desktop.
How to send a SOAP UI request from Java code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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