To test a SOAP service, add its WSDL to an API App. Thunders lists the operations of the WSDL, fills an API Call step from the operation that you pick, and sends the XML envelope of the step. You then check and extract values of the XML response with the same paths and the same Assert and Extract steps as for a JSON response.
Thunders supports SOAP 1.1 and SOAP 1.2 services that a WSDL 1.1 describes. For the setup of an API App, see How do I set up an API App? For the other fields of an API Call step, see How to add an API Call step?
Before you start
You need the Admin role to add or edit an App.
Have the WSDL of the service, and the XSD files that it imports, or a public HTTPS link to the WSDL.
An API App holds one kind of definition: an OpenAPI or Swagger spec, or a WSDL. When your system has REST services and SOAP services, create one API App for each kind.
Add the WSDL to an API App
Open Configure > Apps and select the card of the API App, or create a new API App. The API spec (optional) field takes the WSDL.
Upload: drop the
.wsdlfile and the.xsdfiles that it imports, or select the area to browse. Each file can be up to 10 MB, and the upload up to 50 MB in all. Thunders links an import to an uploaded file by its file name, so keep the file names that the WSDL uses.From URL: enter the link to the WSDL, for example
https://example.com/CalculatorService.svc?wsdl, then select Parse spec. Thunders also downloads the WSDL and XSD files that the WSDL imports by URL.
Then select Save changes. Thunders refuses a file that it cannot use and shows the reason:
"An app holds one kind of definition. Upload the OpenAPI files and the WSDL files on two apps." You uploaded OpenAPI files and WSDL files together.
"This app holds another kind of definition. Remove its spec, or create another app for these files." The App already holds an OpenAPI spec.
"No SOAP binding in the WSDL". The WSDL describes no SOAP service.
"The files are larger than 50 MB in all."
Thunders does not support WSDL 2.0 yet.
The Endpoints section of an App with a WSDL shows "The coverage of the operations of a SOAP service is not available yet."
Fill an API Call step from an operation
Open the Test Case and add an API Call step.
In the Operation list, type in Search operations and select the operation. Each operation shows its name and its port, for example
Multiply · CalculatorSoap. When the Test Project has more than one App with a WSDL, the name of the App comes first.Thunders fills the step:
the HTTP Method
POST;the URL, which starts with the URL variable of the App, for example
[APP_CALCULATOR_URL]/CalculatorService.svc, so the step calls the service of the Environment that the run targets;the SOAP action header of the operation:
SOAPActionfor SOAP 1.1, or theactionparameter ofContent-Typefor SOAP 1.2;an XML body with a sample envelope of the request.
Replace the sample values of the envelope (see the next section).
To write a request without an operation, keep REST request in the Operation list. The Operation list shows only when an App of the Test Project holds a WSDL.
Edit the XML body
In the Body tab, select XML. Two tabs show the body:
Body lists each value of the envelope with its Path. Change a value there without touching the XML around it.
Raw body shows the full XML text. Edit it there to add or remove elements.
Thunders sends the text of the body as it is. You can use variables in the body, for example <intA>[FIRST_NUMBER]</intA>. At run time, Thunders escapes the characters that XML reserves in the value, such as < and &.
When the step sends no Content-Type header, Thunders sends text/xml; charset=utf-8, the type of SOAP 1.1. For SOAP 1.2, add a Content-Type header with application/soap+xml. A step filled from an operation already holds the right header.
When the XML is not well-formed, the editor shows "The XML is not valid." You can still save the step, for example to test how the service answers a broken envelope.
Use WS-Security UsernameToken authentication
When the service asks for a WS-Security username and password, open the Authorization tab and select WS-Security UsernameToken. Enter a Username and a Password, and choose the Password type:
Text: Thunders sends the password as it is.
Digest: Thunders sends a digest of the password, with a nonce and a creation time.
At run time, Thunders adds the UsernameToken to the SOAP header of the envelope. This authentication needs an XML body with a SOAP envelope. As with the other types, the password must be a variable, for example [CALCULATOR_PASSWORD].
Check and extract values of the XML response
Run the step, then select its row to open the response. The Pretty view shows the XML response formatted.
A path into an XML response works like a path into a JSON response. For a step that saves its response as QUOTE_RESPONSE:
[QUOTE_RESPONSE].body.GetQuoteResponse.Pricereads the text of thePriceelement. Thunders skips theEnvelopeandBodylevels and ignores the namespace prefixes.[QUOTE_RESPONSE].body.GetQuoteResponse.@currencyreads thecurrencyattribute.[QUOTE_RESPONSE].body.GetQuoteResponse.Line[1].Skureads the secondLineelement. The count starts at 0.
For a query that a path cannot express, use an XPath 1.0 expression after xpath:, for example [QUOTE_RESPONSE].xpath:count(//ns2:Line). The prefixes of the expression are the prefixes that the response declares.
Use these paths in an Assert step, in an Extract step, and in any field that accepts variables. For the Assert and Extract steps, see API Response Assertions and Variable Extraction.
Understand a SOAP Fault
When the response holds a SOAP Fault, the step fails. Its bug report gives the status, the code and the reason for the fault, for example "SOAP Fault, status 500. Code: s:Client. Reason: Unknown product". This applies even when the service sends the fault with the status 200. The saved response also holds fault.code and fault.reason.
To test a case where the service must send a fault, set Expected status to the status that the service sends with the fault, for example 500. The step then passes, and an Assert step can check [QUOTE_RESPONSE].fault.code.
Generate SOAP tests with Thunders AI
Select the API App with the WSDL in Thunders AI, and describe the test. Thunders AI reads the operations of the WSDL and writes API Call steps with an XML body, the SOAP action header and the checks on the XML response. See How do I set up an API App? for how Thunders AI works with an API App.
Frequently asked questions
How do I test a service that has REST endpoints and SOAP operations?
Create two API Apps: one with the OpenAPI spec, one with the WSDL. A Test Case can call both Apps. An App holds one kind of definition, so Thunders refuses a WSDL on an App that holds an OpenAPI spec.
How do I read an element when two elements have the same name?
Use [n] to pick the element by its position, for example Line[1] for the second one. When the two elements are in two namespaces at the same level, use an xpath: expression with the prefixes of the response.
How do I test a SOAP 1.2 service?
Pick the operation of the SOAP 1.2 port in the Operation list. Thunders sets the Content-Type header to application/soap+xml with the action of the operation. When you write the step yourself, add that header.
How do I make the step pass when the service must return a fault?
Set Expected status to the error status that the service sends, for example 500. The step then expects the fault and does not report a bug. Add an Assert step on fault.code to check the fault.
How do I sign or encrypt the SOAP message?
Thunders adds a WS-Security UsernameToken, in text or digest form. It does not sign or encrypt messages, and it does not support client certificates or MTOM attachments yet.
