Ranorex Logo

How to Test Web Services with Ranorex

|
Test Web Services With Ranorex|Flow Chart|Add Web Reference|Enter URI|Web Reference Files|Web Reference Code|Add Variables|Add User Code Action|Add Argument|View Code|Complete Recording|Report

This blog post will illustrate how easy it is to test your web service using Ranorex. In detail you will add a web reference of your web service to your Ranorex Solution and validate the functionality of the service via user code actions.

To illustrate web service testing, we have chosen an easy to follow example based on sample web service provided by w3schools.com. Basically we will take a given temperature in Celsius, convert it to Fahrenheit and reconvert it back to Celsius. Finally we compare the calculated value with the initial one.

Flowchart2-scaled-1
  • What is a Web Service
  • Adding Web References to your Solution
  • Accessing the Web Service
  • Testing the Web Service
  • Conclusion

What is a Web Service

The W3C defines a web service as a software system designed to support interoperable machine-to-machine interactions over a network. It has an interface described in a machine-processable format called the web service description language (in short: WSDL). Other systems interact with the web service by the mentioned description using SOAP messages. Those messages are typically conveyed via HTTP using XML serialization together with other web-related standards.

Summarizing we can say that it is an interface to quickly provide functionality over a network, such as adding two numbers and retrieving the result. For instance each type of cloud computing is using web services nowadays.

Ranorex allows adding web services as web references to your Ranorex solution. This means that you can access and in further consequence test web services using Ranorex.

Let’s now have a look on how you can test your web service based on the following web service example that converts Celsius to Fahrenheit (and vice versa):

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

Adding Web References to your Solution

Create a new Solution in Ranorex Studio. Add a web reference by right-clicking the References folder in Project View and choosing “Add Web Reference”.

Add-Web-Reference

Enter the URI of the web service to the address bar and press the “Go” button. The “WSDL” tab will automatically give you a description of the provided functionality. Enter a speaking reference name as well as a speaking namespace through which you want to access the service.

Enter-URI1

Accessing the Web Service

After adding the web reference you will see a new folder “Web References” within your “Projects” view. When opening the folder you will see the just added web service holding an automatically generated class “Reference.cs” including methods provided by the service.

Web-Reference-File1
Web-Reference-Code1

The automatically generated class allows you to access the web service directly. There are two different approaches to do that: user code actions as well as code modules. In this blog we will treat the first approach user code actions in combination with validation actions and variables.

To start over, open an existing or create a new recording in your solution and add two variables, one holding the initial value named initialTemperature and one holding the calculated value named calculatedTemperature.

Add-Variables2

Add a new user code action and name it CelsiusToFahrenheit. Add an argument named temperature using the item argument editor. Bind the variable initialTemperature to the argument temperature.

Add-User-Code-Action1
Add-Argument2

Right-Click the added action and choose “View Code” to add functionality to your user code action.

View-Code4

Update the generated code as follows:

public partial class Recording1
    {
    	TempConvert.TempConvert converter;

        private void Init()
        {
        	converter = new TempConvert.TempConvert();
        }

        public void CelsiusToFahrenheit(string temperature)
        {
        	calculatedTemperature = converter.CelsiusToFahrenheit(temperature);
        }

}

We add a member converter (from namespace TempConvert and class TempConvert as defined when adding the web reference) to our recording class which has to be created in the Init method.

When calling the user code action CelsiusToFahrenheit, the value stored in variable initialTemperature will be taken as argument for the web service. The calculated temperature (return value of the web service) will be stored in the variable calculatedTemperature for further processing in the recording.

Testing the Web Service

Now, as we know how accessing a web service works, we want to validate whether or not our methods provided by the web service operate correctly. Therefore we add an additional user code action calling the FahrenheitToCelsius service as well as an action validating whether conversion and reconversion work as expected. Doing this, the user code might look as follows:

public partial class Recording1
    {
    	TempConvert.TempConvert converter;

        private void Init()
        {
        	converter = new TempConvert.TempConvert();
        }

        public void CelsiusToFahrenheit(string temperature)
        {
        	calculatedTemperature = converter.CelsiusToFahrenheit(temperature);
        	Report.Info(temperature + "°C = " + calculatedTemperature + "°F");
        }

        public void FahrenheitToCelsius(string temperature)
        {
        	calculatedTemperature = converter.FahrenheitToCelsius(temperature);
        	Report.Info(temperature+ "°F = " + calculatedTemperature + "°C");
        }

        public void AreEqual(string actual, string expected)
        {
        	Validate.AreEqual(actual, expected);
        }
    }

The recording and the corresponding report will then look like this:

Complete-Recording3
Report1

As you can see in the given report, in the first step 10° Celsius are converted to 50° Fahrenheit. In the second step the calculated 50° Fahrenheit is converted back to 10° Celsius. The last step validates whether the initial value equals the calculated one (or not). In this very case the web service operates as expected since the validation was successful.

Conclusion

In the preceding sections, we saw that accessing and testing web services is pretty easy. All you need is a little bit of programming skills after the web service has been added to your solution as a web reference. To get the most out of your user code, also have a look at the corresponding chapters in our user guide:

In This Article

Sign up for our newsletter

Share this article

Related Articles

Load-Testing-Tools-Compared-JMeter-vs-k6-vs-Gatling-vs-Locust-blog-image

Load Testing Tools Compared: JMeter vs k6 vs Gatling vs Locust

April 9, 2026
Your API response times look fine in development. Then you deploy, a Reddit post goes viral, and suddenly you’re troubleshooting 503 errors while your database melts. Load testing prevents this scenario by surfacing bottlenecks before production traffic finds them. Four ope...
Automated-Functional-Testing-Strategy-Tools-and-Scalability-blog-image

Automated Functional Testing: Strategy, Tools, and Scalability

March 19, 2026
Developers face constant pressure to deliver bug-free applications under tight deadlines. That’s a tall order, especially considering that products must adapt to different device types and user interfaces (UI) across desktop and mobile. One tool that can help is automated f...
What-is-smoke-testing-A-complete-guide-for-QA-teams-and-test-automation-blog-image

What Is Smoke Testing? A Complete Guide for QA Teams and Test Automation

February 26, 2026

Smoke testing is a critical part of software development that should be done early and often. Using automated smoke test software can save time and money.