A free SOAP API for testing, with a WSDL
A calculator service with a WSDL and a countries service, both answering SOAP 1.1 and 1.2.
Examples last run against the API on
For a public SOAP API to test a client against, use https://api.testingapis.com/api/soap/calculatorsign in to see. Its WSDL is at https://api.testingapis.com/api/soap/calculator?wsdlsign in to see, and SoapUI, Postman, WCF and Python's zeep can import it. It has four operations: Add, Subtract, Multiply and Divide. It accepts SOAP 1.1 and SOAP 1.2 and returns proper SOAP faults, so you can test errors as well as results. A second service, /api/soap/countriessign in to see, returns structured country records. Both are free with an account: send your API key in the X-TestingApis-Key HTTP header, next to SOAPAction.
| Calculator | Countries | |
|---|---|---|
| Endpoint | POST /api/soap/calculatorsign in to see | POST /api/soap/countriessign in to see |
| WSDL | GET /api/soap/calculator?wsdlsign in to see | None. GET the endpoint for usage JSON and a sample envelope |
| Namespace | http://tempuri.org/ | http://example.com/countries |
| Operations | Add, Subtract, Multiply, Divide (integers) | GetCountryInfo(countryCode), ListCountries() |
| Versions | SOAP 1.1 and 1.2 | SOAP 1.1 and 1.2 |
Call it with curl (SOAP 1.1)
SOAP 1.1 uses Content-Type: text/xml and a SOAPAction header naming the operation. The header is optional here, but if you send it, it must match the operation in the body.
curl -X POST https://api.testingapis.com/api/soap/calculator \
-H 'Content-Type: text/xml; charset=utf-8' \
-H 'SOAPAction: "http://tempuri.org/Add"' \
-d '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/"><intA>5</intA><intB>3</intB></Add>
</soap:Body>
</soap:Envelope>'HTTP/1.1 200 OK
content-type: text/xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>8</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>SOAP 1.2 and faults
SOAP 1.2 uses Content-Type: application/soap+xml, a different envelope namespace and no SOAPAction header. The response comes back in the same version as the request. Dividing by zero returns a Receiver fault:
curl -X POST https://api.testingapis.com/api/soap/calculator \
-H 'Content-Type: application/soap+xml; charset=utf-8' \
-d '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<Divide xmlns="http://tempuri.org/"><intA>10</intA><intB>0</intB></Divide>
</soap:Body>
</soap:Envelope>'HTTP/1.1 500 Internal Server Error
content-type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Attempted to divide by zero.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>The fault rules follow the specifications, which is what a client needs to be tested against:
| Case | SOAP 1.1 | SOAP 1.2 |
|---|---|---|
| Bad input (unknown country code) | 500, faultcode soap:Client | 400, Code soap:Sender |
| Server-side error (divide by zero) | 500, faultcode soap:Server | 500, Code soap:Receiver |
| SOAPAction names a different operation | 500 fault | Not applicable |
| Wrong Content-Type (e.g. JSON) | 415 with a JSON error | 415 with a JSON error |
Use it from a SOAP client
SoapUI
- Choose File, then New SOAP Project.
- Paste
https://api.testingapis.com/api/soap/calculator?wsdlsign in to see as the initial WSDL and finish. SoapUI creates a request for each operation in both bindings. - Open a request, fill in
intAandintB, and run it.
Python with zeep
zeep reads the WSDL and builds a typed client from it, and SOAP faults become Python exceptions:
# pip install zeep
from zeep import Client
client = Client("https://api.testingapis.com/api/soap/calculator?wsdl")
print(client.service.Add(intA=5, intB=3))
print(client.service.Multiply(intA=6, intB=7))
try:
client.service.Divide(intA=10, intB=0)
except Exception as err:
print(type(err).__name__, err)8
42
Fault Attempted to divide by zero.JavaScript with fetch
Without a SOAP library, a request is an XML string and the result is read out of the response text:
const envelope = `<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Multiply xmlns="http://tempuri.org/">
<intA>6</intA>
<intB>7</intB>
</Multiply>
</soap:Body>
</soap:Envelope>`;
const res = await fetch("https://api.testingapis.com/api/soap/calculator", {
method: "POST",
headers: {
"Content-Type": "text/xml; charset=utf-8",
SOAPAction: '"http://tempuri.org/Multiply"',
},
body: envelope,
});
const xml = await res.text();
console.log(res.status, xml.match(/<MultiplyResult>(.*?)<\/MultiplyResult>/)[1]);
// 200 42The countries service
The calculator only returns numbers. To test parsing nested records, use the countries service. It has 10 countries (US, GB, IN, DE, FR, JP, BR, CA, AU and ZA). ListCountries returns codes and names, and GetCountryInfo returns one full record:
curl -X POST https://api.testingapis.com/api/soap/countries \
-H 'Content-Type: text/xml' \
-d '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCountryInfo xmlns="http://example.com/countries">
<countryCode>IN</countryCode>
</GetCountryInfo>
</soap:Body>
</soap:Envelope>'<GetCountryInfoResponse xmlns="http://example.com/countries">
<Country>
<Code>IN</Code>
<Name>India</Name>
<Capital>New Delhi</Capital>
<Currency>INR</Currency>
<PhoneCode>+91</PhoneCode>
<Continent>Asia</Continent>
<Population>1428627663</Population>
</Country>
</GetCountryInfoResponse>An unknown code returns a client fault:
HTTP/1.1 500 Internal Server Error
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Country code 'ZZ' not found.</faultstring>
</soap:Fault>Related APIs
The SOAP API reference lists every operation with ready-to-send envelopes. To test a client that consumes XML over plain REST, try the XML users API. The JSON to XML converter helps when comparing a SOAP payload with its JSON equivalent. To learn SOAP from the start, including WSDL, faults, XPath and a Java test suite, follow the SOAP and XML tutorial.