how to test web servicesIn the past several years, the landscape of web development has been changing. There has been a shift away from a relatively small number of large applications toward a relatively large number of small applications. Web services were not fast enough to be interesting. More developers are performing testing, early and more frequently in development instead of quality assurance (QA). The QA job has become more intellectual and less rudimentary because of the asynchronous nature of business process services. Testing was the last stop: beta, beta, beta, with little alpha paternal support for his little beta brats. Fortunately, testing has become a continuing activity in the process of development. Testing web services ensures the functional quality of the product.

Learn how to work with Amazon web services and integrate them into your projects at

Testing Web Services

Web services are application components that communicate using open protocols. They are self-contained and self-describing. They can be discovered using UDDI and can be used by other applications with HTTP and XML as the basis.

One way you can test web services is by calling web methods from unit tests. It is much like testing other code by using unit tests, using Assert statements. The same range of results is produced. There are two ways to test web services with unit tests:

Learn Web Services using Java from

Testing a Web Service Locally

Follow this process to test a Web service that runs on your local computer, but not in IIS:

  1. On the local file system, create the Web service.
  2. Using the standard way to generate unit tests, generate the against the Web service.
  3. Add the AspNetDevelopmentServerAttribute to the unit test.
  4. Add a call to the TryUrlRedirection method, within the unit test. Verify that it returns true, and use an Assert statement to fail the test if the redirection fails.
  5. Call the Web service and test thoroughly in any way you deem necessary.

Unit Tests for ASP.NET Web Services

Unit test for ASP.NET need to contain an .aspx file. Make sure you have the IIS 6 Metabase and IIS 6 Configuration Compatibility.

To add an .aspx file

Do not skip this step. Your unit test with not run unless an .aspx file is in the project that contains your ASP.NET Web service. You can create unit tests without this file, but the test will not actually run, even though it will alert you that it did.

  1. In Solution Explorer, right-click the project that contains your ASP.NET Web service.
  2. Click Add, and then click New Item.
  3. In the Add New Item dialog box, under Installed Templates, click Web.
  4. In the list of Web templates, click Web Form, and then click Add.

Three files have been added to your project: WebForm1.aspx, WebForm1.aspx.cs, and WebForm1.aspx.designer.cs. Do not use or modify these files.

When generating a unit test for an ASP.NET Web service

For cloud computing with Amazon web services, click here.

How to Create a Web Service Test

You can test Web services by using a Web performance test. You will need Visual Studio Ultimate to perform this process.

To test a Web service

  1. Create a new Web performance test. As soon as the browser opens, select Stop.
  2. In the Web Performance Test Editor, right-click the Web performance test and select Add Web Service Request.
  3. In the Url property of the new request, type the name of the Web service.
  4. Open a different session of the browser and type the URL of the .asmx page in the Address toolbar. Select the method that you want to test and examine the SOAP message.
  5. In the Web Performance Test Editor, right-click the request and select Add Header.
  6. In the Name property, type SOAPAction.
  7. In the Value property, type the value in SOAPAction.
  8. In the String Body node, enter text/xml in the Content Type property.
  9. Return to the browser from step 4, select the XML portion of the SOAP request from the Web service description page and copy it to the clipboard.
  10. Return to the Web Performance Test Editor and then select the ellipsis in the String Body property. Paste the contents of the clipboard into the property.
  11. In order for the test to pass, replace any placeholder values in the XML with valid values.
  12. Right-click the Web service request and select Add URL QueryString Parameter.
  13. Assign the query string parameter a name and value.
  14. Run the test. In the top pane of the Web Performance Test Results Viewer, select the Web service request.
  15. In the bottom pane, select the Web Browser tab. The XML that is returned by the Web service, and the results of any operations, will be displayed.

Performance Testing students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo