Click here to Skip to main content
Click here to Skip to main content

Test Your ASP.NET WebService using SoapUI

By , 8 Aug 2009
 

Table of Contents 

Introduction

We have developed web services for different purposes. Authorized users can consume the web service and can use it. soapUI [^] is one of most powerful tools to test our web service. It is able to test any kind of web service, but here I will explain how to test an ASP.NET web service using SOAP UI.

Before you start reading this article, I assume that you have a basic knowledge of the following:

  • Building and Consuming Web Services
  • SOAP Request and Response

This is the basic work through testing of .NET Web services.

Why Should We Need This?

This is one of the best ways to test our web service before we move to production or release. Generally we create a web service and create a sample consumer application to test it. But using Soap UI, we do not need to create the consumer. We can even test our web service based on our Soap Request and Response. I have described all the basic things that we can do with Soap UI tool. You can now explore it and take it forward.

What is soapUI Tool?

soapUI is a tool for Testing Web Services. These can be the SOAP Web Services as well RESTful Web Services or HTTP based services. soapUI is Open Source and a completely free tool with a commercial companion -soapUI Pro- that has extra functionality for companies with mission critical Web Services.

soapUI has been downloaded more than a million times and is seen as the de facto standard for Web Service Testing.

The above text is quoted from the Soap UI site itself. Please visit the SOAP UI [^] site for more details about installation and other guides.

Create a Sample Web Service for Test with soapUI

I have created a small sample web service to test using Soap UI. This web service contains 4 dummy methods, Addition(), Subtraction(), Multiplication(), Division() and getmessage(). I have shown how we check Soap Request and Response during transmission of data.

Have a look at the web service.

Following is my WSDL URL:

http://localhost/MyWebService/Service.asmx?WSDL

Below is the sample code for those methods that I have discussed:

  //Get Sample Message from Web Service
   [WebMethod]
    public string GetMessage() {
        return "Sample Web Service For Test with soapUI";
    }
    
    // Add two number
    [WebMethod]
    public int Addition(int a,int b)
    {
        return a + b ;
    }
    
    //Subtract Two number
    [WebMethod]
    public int Subtraction(int a, int b)
    {
        return a - b;
    }
    
    //Multiply Two Number
    [WebMethod]
    public int Multiplication(int a, int b)
    {
        return a*b;
    }
    
    //Division of Two number
    [WebMethod]
    public float Division(int a, int b)
    {
        return a/b;
    }

Start Testing With soapUI

I hope you have already gone through the soupUI web sites and done the necessary installation. Now start the soapUI.

Open SoapUI

At the beginning, it will start a command prompt to initialize the soapUI tool. It looks like:

Simultaneously , the UI of soapUI will be open, which will look like:

Start a New Project

So, before we start testing our web service, we have to create a new project from File > New soapUI Project. The following screen will come:

On this screen, we have to provide the ProjectName and WSDL URL. I have marked that area with red color. After providing both the information, click on "OK" . After click on OK button, soapUI will start loading the definition of web service request and response. It will show a progress bar while doing this process:  

Exploring soapUI

After completion of this process, check out the Navigator panel, where you can see a project name has already been created and all the methods of your web service are available with a default request.

In the bottom section of navigator window, you can see the properties of our web services, which includes port type, wsdl url, binding , SOAP Version, etc.

Similarly, if we click on the particular method, we will also get the details like SOAP Action header, Type, Description for each and every method. For example, if I clicked on "Addition()" method, the following display will come in the property window.

Check SOAP Request

Now, we come to the main point. This is about the SOAP request. We can easily get the SOAP Request for any particular method. As for example, if we click on the Request of Addition() methods, it will show the following SOAP Request for the Addition Method. So before checking the SOAP request, just have a quick look at the Addition() method. It was something like:

 // Add two number
    [WebMethod]
    public int Addition(int a,int b)
    {
        return a + b ;
    }

So, this web method accepts two integer parameters and returns the sum of those two numbers as integer. Now, check the SOAP XML format for that method.

Click to enlarge image

In the SOAP Request, it clearly shows the accepted parameter. Now let's see the SOAP Response if we pass some parameters on that SOAP Request.

Check SOAP Response 

For example, I am passing 1 and 2 as parameters of SOAP Request, and click on the "Run" button, it will give you the following output:

Click to enlarge image

From the SOAP Response, we can easily understand that our web service is returning valid data. If we click on the RAW tab, we will get the RAW XML Format for the requests and response.

The example which I have explained is for an simple method. We can test for many complex methods too.

Summary 

This is not an article for describing what Web Services, SOAP Request or SOAP Response are. This is all about how to test your web service after it has been developed. SOAP UI is one of the best web service testing tools for testing Soap Requests and Responses. In this article, I have explained only the basic overview of that tool. May be at a later point, I will come up with some advanced features of this tool. Hope this will help you in future to test your web service. Please give your valuable suggestions and feedback.

Points of Interest 

This is a great tool to test our web service to make sure it is working fine before we deliver it to the client or customer.

History 

  • 9th August, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Abhijit Jana
Software Developer (Senior)
India India
Member
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband
 
Blog : http://abhijitjana.net
Web Site : http://dailydotnettips.com
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralHelp Full Articlemembersushil12345655518 Apr '12 - 0:07 
Help Full Article
GeneralMy vote of 5membermanoj kumar choubey5 Apr '12 - 1:25 
Nice
GeneralMy vote of 5memberrajeevtechnical16 Mar '11 - 6:57 
Simple and Sufficient
GeneralMy vote of 5memberMember 332542311 Jul '10 - 23:05 
Nice One.Can we do the load testing in Web service by using the same tool
GeneralOutstanding toolmemberBOWLINGBALL12 Aug '09 - 4:31 
I searched and search until I found this tool and it saved hours upon hours.
 
Thanks a million
GeneralRe: Outstanding toolmvpAbhijit Jana12 Aug '09 - 6:26 
Yes. This is an Excelent Tool Thumbs Up | :thumbsup:
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article

GeneralExcellentmemberAbhishek Sur10 Aug '09 - 3:47 
Thanks for the lovely article.
 
5 from me Thumbs Up | :thumbsup:
 
Abhishek Sur

My Latest Articles
Create CLR objects in SQL Server 2005
C# Uncommon Keywords
Read/Write Excel using OleDB

Don't forget to click "Good Answer" if you like to.

GeneralRe: ExcellentmvpAbhijit Jana10 Aug '09 - 7:00 
cheers Mate Beer | [beer]
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article

QuestionWhere you tested webservice?mvpN a v a n e e t h9 Aug '09 - 9:38 
Article title reads "Test Your ASP.NET WebService using SoapUI". Well, I couldn't find where you are testing the web service? All you are doing is just displaying the raw SOAP message. It can be done by running the WS on a browser and invoking the methods from browser without using any extra tools.
 

AnswerRe: Where you tested webservice?mvpAbhijit Jana9 Aug '09 - 10:00 
N a v a n e e t h wrote:
Well, I couldn't find where you are testing the web service? All you are doing is just displaying the raw SOAP message.

If you check the SOAP Requets section, then you can see that, How I am passing argument throug SOAP Request and what is the exact SOAP Response.
Though the Example is very simple but this tool having many more functionality that you can check it from the SOAP UI web site. And I have just covered the basic.
N a v a n e e t h wrote:
It can be done by running the WS on a browser and invoking the methods from browser without using any extra tools.

No. This is not always correct. If you are developing your Web Service in VS or Accessing from local host only you will able to get the textbox for the corresponding input. But You will not able to do the same if your web services is hosted on different server and you want to test it from another server ( on the click of web method you will get the soap message format only )
 
Navaneeth : if you have any further improvement suggestion please let me know Big Grin | :-D
 
Thanks for your feedback Big Grin | :-D
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article
modified on Sunday, August 9, 2009 4:09 PM

GeneralRe: Where you tested webservice?mvpN a v a n e e t h9 Aug '09 - 15:30 
Abhijit Jana wrote:
if your web services is hosted on different server and you want to test it from another server

 
Aahh, that makes much sense. Smile | :)
 

GeneralRe: Where you tested webservice?mvpAbhijit Jana9 Aug '09 - 17:25 
Smile | :) Thumbs Up | :thumbsup:
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article

GeneralOutstandinggroupMd. Marufuzzaman9 Aug '09 - 5:19 
It's excellent.. I have some queries on that..
 
As we know we can add the WSDL uri as reference in .Net & the application may win/web.. How can we call a SOAP object using hard coded script in .Net app... Or if we want to call from a Php / vbScript as well.
 
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
 
Thanks
Md. Marufuzzaman

GeneralRe: OutstandingmvpAbhijit Jana9 Aug '09 - 9:01 
Thanks Md. Marufuzzaman.
 
Md. Marufuzzaman wrote:
How can we call a SOAP object using hard coded script in .Net app

 
I didn't get your question. Can you please explain it in details. We are generally create the proxy of WSDL url either Visual Studio or using wsdl.exe and then we can use the web method. But I am not able to under stand "hard coded script".
Please explain in details.
 
Thanks Big Grin | :-D
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article

GeneralRe: OutstandinggroupMd. Marufuzzaman9 Aug '09 - 9:05 
Thanks for your prompt response, Actually how can we call SOAP object using vbScript. Do you have any idea?
 
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
 
Thanks
Md. Marufuzzaman

AnswerRe: OutstandingmvpAbhijit Jana9 Aug '09 - 9:41 
Md. Marufuzzaman wrote:
Actually how can we call SOAP object using vbScript. Do you have any idea?

This may help you Big Grin | :-D
Calling a Webservice from VBScript or ASP
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
View My Latest Article

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 8 Aug 2009
Article Copyright 2009 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid