Creating/Consuming Web Service in VisualStudio.NET

Summary

Web Service Namespaces

The following namespaces support Web Service requirements:

Namespace Notes
System.Web.Services Minimal and complete set of types required to build a Web Service.
System.Web.Services.Description Allows you to programmatically interact with WDSL.
System.Web.Services.Discovery Allows you to programmatically discover the Web Services installed on a machine.
System.Web.Services.Protocols Defines a number of types that represent the wire protocols used to exchange information between a Web Service and its consumers.

Web Service files in vs.net

The core files of a VS.NET Web Service project are as follows:

Web Service Project File Note
.asmx
.asmx.cs
These files define the methods of the Web Service. Each .asmx file has a corresponding Web .asmx.cs file to hold the code behind the form itself.
.disco This extension is short for 'DISCOvery of Web Services' and contains an XML description of the web services at a given URL.

Creating Web Services in VisualStudio.NET

(VisualStudio.NET Project template is: ASP.NET Web Service)

Creating an ASP.NET Web Service in VisualStudio.NET is very easy and straightforward. Here is how VisualStudio.NET lightens your load:

  1. VisualStudio.NET creates a new sub-Web in IIS as well as the associated folder on the local HD.
  2. All you have to write is the method itself.
  3. VisualStudio.NET uses syntax highlighting and uses IntelliSense pop-up windows to help write code more quickly.
  4. You do not have to create the WSDL document. VisualStudio.NET creates it automatically based on the methods and parameters in your class.
  5. VisualStudio.NET offers easy access to the test harness.
  6. VisualStudio.NET automatically supplies other files such as a .vsdisco file.

Consuming Web Services in VisualStudio.NET

(VisualStudio.NET Project template is: ASP.NET Web Application)

A Web Service can be consumed (or used) by any type of application running on virtually any computer running almost any software (in theory). Creating an ASP.NET Web Application in VisualStudio.NET is very easy and straightforward. Here is how VisualStudio.NET lightens your load:

  1. VisualStudio.NET creates the required files for you and the sub-Web in IIS.
  2. You are able to create and add a Web Reference by simply navigating to it in Server Explorer, popping up the Context Menu on your Web Services.
  3. VisualStudio.NET takes care of creating and compiling the proxy.
  4. You create the Web Forms application by simply dragging and dropping controls onto the designer window.
  5. VisualStudio.NET uses syntax highlighting and uses IntelliSense pop-up windows to help write code more quickly.
  6. You can view and test the Web Forms application within the IDE by simply choosing View in Browser from the pop-up menu on the Web Forms page.

Hints

If you come across some error such as "No Web References were found on this page"  when you attempt to add a reference to web service, or if View in Browser generates HTTP errors, then you could try a few things:

<add verb="*" path="*.vsdisco" type="System.Web.Services.Discovery.DiscoveryRequestHandler, System.Web.Services, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>