Skip to main content

Using Postman for calling a SOAP Web Service

So testing Web Services and REST APIs is not something that I have regularly spent a great deal of time doing (although I have done some). However, a change to a customers requirements meant that I had the opportunity to test a SOAP Web Service in a little more depth. Now I have used Postman to test Rest APIs but I had not used it to test SOAP Web Services. I wasn't sure If I could do it but I thought I would give it a go... 

So in this post I will show how you can use Postman to test a SOAP Web Services via the postman UI and the sendRequest method.

So what did I do?
The service I will use for this blog post is one provided by W3schools which converted Celsius to Fahrenheit and Visa Versa. Here it is :) 

https://www.w3schools.com/xml/tempconvert.asmx

So first of all I had to work out how to call a SOAP Web Service using postman. So a quick look on the Postman web site and I found that I needed to:

  •  Set the URL to be the Soap Endpoint
  •  Set the request method to POST
  •  Open the Raw editor and set the body type as text/xml
  •  Enter the SOAP message in the request body

So my request looks like this:




However, this did not work. The content-type key in the header of my request was defaulted to application/xml and I had to change it to text/xml. After changing this I got a response. 

Here it is:




So happy days!!! I have called a SOAP Web Service using Postman. 

However, what happens if I want to call another SOAP Web Service using a value returned from the Fahrenheit to Celsius as a parameter. Well Postman makes it easy.....

Postman provides a pm object and within this object is a method called sendRequest. This allows you to send a request to a service using Javascript. This sendRequest method can have the following parameters:

url - This is the URL of the service you want to call
Method - This is the request method (POST, GET etc..)
Header - The header values
Body - The body of the request

So for my example my code looks as follows:



I added the above code to the Tests scripts tab so that when my original request returns the Celsius value, this test script will run. It takes the Celsius value returned by the FahrenheitToCelsius call and uses that as the Celsius value in the CelsiusToFahrenheit call. 

So the 2 lines at the top of my Test get the Celsius value from the response of my original web service call and place it in a variable called Celsius. The body of the service call is populated with the SOAP message for the CelsiusToFahrenheit service call and the Celsius value is put into this message via the following piece of xml:

+ Celsius + 

This sendRequest will now send a CelsiusToFahrenheit SOAP Webservice call using the value in the Celsius variable as the Celsius. 

The final piece of my code in the tests tab looks like this:



What this piece of code does is tests that the response from  CelsiusToFarenshei is equal to 100. 

So there you go. A nice example of how Postman can be used to test SOAP Web Service calls as well as how you can call a SOAP web service from within the tests section of a request using a variable that was populated from the response of the original request.







Comments

Popular posts from this blog

How to deal with pauses and timeouts in specflow

So this blogpost is in response to the weekly Specflow blog posts and challenges that have been written by Gojko Adzic. This weeks challenge was how would you rewrite or rephrase the below scenario: Given a user registers successfully When the account page reloads And the user waits 2 seconds Then the account page displays "Account approved" My initial though was something like this: Given a user registers successfully  When the account page reloads   Then the account page is displayed within a satisfactory time period     And the account page displays "Account Approved" Now the problem with this scenario is what defines a satisfactory time? You could add it as a comment or in a scenario outline but over time the time a user waits could change and if this is updated in the code behind but the scenario outline or comments are not, then what the test does and what is described do not match - this would potentially cause issues in the future. My next ide

Testing and Mindfulness

How aware are you? Do you live in the here and now or is your mind always somewhere else? This blog post is about Mindfulness. Mindfulness is a simple meditation and is defined as (According to Wikipedia): "The intentional, accepting and non-judgemental focus of one's attention on the emotions, thoughts and sensations occurring in the present moment" Now Mindfulness has become more popular in the west in recent years as it has shown to have benefits for people who are suffering from Depression and Anxiety. It has been around for a while and is often thought to of originated from Buddhism and some people believe it started thousands of years ago. Now modern life is hectic and I’m sure we all have lots of things going on in our lives that keep our Brains busy and trying to focus on one thing at a time can be a challenge. I can't remember the number of times I've been doing something and my mind is somewhere else entirely. Mindfulness helps you focus on

Building a test strategy for a new team

Teams, we have all been on them. Some are good and some are bad. Some we never wanted to leave and others we probably couldn't wait to leave. Now most of the time (well in my experience anyway) you tend to get put into a team that already exists. Maybe you are a new hire or maybe you have asked to change to a different product team.  When you do this, more than likely there will already be a testing strategy in place. It may be that you adapt it and change it in any way you see fit to improve the testing. But imagine if everyone on the team was new? How would you decide your testing strategy? This post will go through some useful things you can do to help a new team develop a test strategy. Table of Contents πŸ“ˆ What is a Test Strategy? πŸ€” Where should I start? 🎯 Understand the company and their goals πŸ’ͺ Play to the teams strengths πŸ‘️‍πŸ—¨️ Understand what quality looks like πŸ“ Understand Scope πŸ§ͺ Understand the type of tests you need πŸ“Š Measure your success 🀝 Collaborate πŸ“ Summar