Tutorial · Test Automation
Testing SOAP WebServices using REST-Assured Library
REST-Assured has no native SOAPAction method. This article explores a method for using REST-Assured to send requests to SOAP services despite that limitation.

In this article3 sections
REST-Assured is a library that is specifically designed for testing REST API services. However, what if you want to test both REST and SOAP API services using a single framework? Fortunately, it is possible to use REST-Assured for testing both types of APIs. Although REST-Assured supports XML format, it does not have a native SOAPAction method for sending requests to SOAP services.
In this article, we will explore a method for using REST-Assured to send requests to SOAP services despite this limitation.
Getting the SOAPAction value from WSDL
To demo, I am using a public SOAP webservice from https://www.crcind.com/csp/samples/SOAP.Demo.cls
The WSDL file is present at https://www.crcind.com/csp/samples/SOAP.Demo.CLS?WSDL=1 and is loaded into SoapUI to do a quick sanity check for sending a sample request.


The value of the SOAPAction field is to be noted and feeds into the header in the REST Assured call. The operation we are interested in is the addition operation and hence the http://tempuri.org/SOAP.Demo.AddInteger is copied
REST-Assured code for SOAP Call
public void RESTAssuredSOAPCall() throws IOException {
File requestBody = new File(getClass().getClassLoader().getResource("addition-requestbody.xml").getFile());
Response response = RESTAssured.given()
.baseUri("https://www.crcind.com:443")
.basePath("/csp/samples/SOAP.Demo.cls")
.header("SOAPAction", "http://tempuri.org/SOAP.Demo.AddInteger")
.header("Content-Type", "text/xml; charset=utf-8")
.body(requestBody)
.post();
assertEquals(200,response.statusCode());
System.out.println(response.prettyPrint());
}The request payload is saved in the addition-requestbody.xml file which is read and passed into the body().




