Postman Tutorial Part 54 – Testing SOAP API(WSDL) Using Postman
As a part of Postman Tutorial – End to End, in this post, we will learn to test a SOAP API using the Postman tool.
The purpose of this post is to make you aware that the Postman tool is not only for the REST API Testing. We can test REST, SOAP, and GraphQL requests directly within Postman. Although more than 71% APIs are developed using REST and now GraphQL is also being used. But there are some traditional APIs that are based on SOAP and you may need to interact with them sometimes. So having knowledge of testing a SOAP API using the Postman tool will be good. It is also asked in interviews as well.
- You should have a preferably native Postman app installed on your system.
SOAP APIs for Demo
Steps to test SOAP APIs in Postman
Launch Postman tool
Make sure the Postman tool is installed in our system. If not then download it from here. Launch it after downloading and installing,
Enter SOAP API URL in the address field of request builder section
Let’s use Calculator WSDL for this demo. Copy and paste Calculator WSDL in the address bar as below. Select the HTTP method as POST as mostly SOAP APIs use POST. It may be GET also which can be confirmed from the API documentation which is provided by APIs developers.
Enter request body in XML
Since APIs based on SOAP supports XML as a message format, we need to pass XML request body. Ideally, you should get an API document where the expected request body of an API will be given. You can see that information is given in demo SOAP APIs provided by Postman here. It gives information like supported HTTP method, required headers, and expected request body.
But for Calculator APIs we do not have any documents. Sometimes a developer will share only the WSDL file. In that case, you can use SOAP UI tool to know operations supported by the WSDL file and their request body and other information about APIs.
You can download and install SOAP UI Open Source from the link. installation is very easy like any other normal software. Once installed launch it.
Click on “SOAP” to create a new SOAP project.
Enter WSDL in “Initial WSDL” field. It will fetch the project name automatically. Make sure you have checked “Create sample requests for all operations“. It is by default checked. Click on “OK“.
You should see the project will be loaded with all possible operations from WSDL i.e. add, divide, multiply, and subtract.
When we expand any operation we will see the request body. To see request body click on “Request 1“.
Copy whole XML request body and paste in Postman request body.
You may be thinking we copied request for “add” operation from SOAP UI then there should be a different URI for that operations as well. It is generally followed in REST APIs but in SOAP, WSDL has all the information on supported operations. So which operations will be performed that depends upon the request body. If you observe above XML request body carefully, you can see <exam:add>. It represents an “add” operation. Similarly, you can see different request bodies in SOAP UI and observe the difference.
Set input values in XML request body
Once we get the expected request body then we need to fill in required values. For the above SOAP API, we need to pass values of intA and intB which we see in XML body. You need to be aware of functionalities and expected input values of APIs.
Set header values for the request
Generally, we need to set Content-Type for SOAP APIs as text/xml. This information you can get from API documentation as well. Remember for older SOAP APIs or REST APIs, application/xml will not work.
Hit the “Send” button
When we hit the “Send” button, we will get an XML response for this API. A response may be a normal text or different format other than XML as well. That all depends on APIs. You can see the status code as well.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Find all Selenium related posts here, all API manual and automation related posts here, and find frequently asked Java Programs here.
Many other topics you can navigate through the menu.