Professional Documents
Culture Documents
Create a Sample Web Service for Test with soapUI Start Testing With soapUI o Open SoapUI o Start a New Project o Exploring soapUI o Check SOAP Request o Check SOAP Response Summary Points of Interest History
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.
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.
http://localhost/MyWebService/Service.asmx?WSDL
Below is the sample code for those methods that I have discussed:
Collapse Copy Code
//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; }
Open SoapUI
At the beginning, it will start a command prompt to initialize the soapUI tool. It looks like:
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.
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.
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.
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.