Creating XML Web Services with Visual Studio .NET

Microsoft Visual Studio® .NET natively provides extensive XML Web services functionality. XML Web services can be created in Microsoft Visual Basic® .NET, Microsoft Visual C#™ .NET, Microsoft Visual C++® .NET, or any other language supported by the common language runtime.

To create an XML Web service using Visual Studio .NET:

  1. Start a new project, and select ASP .NET Web Service to build an XML Web service using either Visual C# or Visual Basic, or select Managed C++ Web Service to build an XML Web service using Visual C++.

  2. Enter a name for the XML Web service and a location at which the XML Web service will be deployed, and then click OK to generate the XML Web service project.

  3. Visual Studio .NET creates a project (in your language of choice) that imports the namespace System.Web.Services and adds a class that is derived from System.Web.Services.WebService. This class will implement the XML Web service.

     Imports System.Web.Services

     Public Class MyWebServiceClass

     Inherits System.Web.Services.WebService

  1. Add methods to the class that implement the various Web methods. In this case, we have created methods to debit, credit, and check a customer's credit in real time at the customer's bank. To designate the method as an XML Web service, simply prepend each method with a WebMethod attribute.

     <WebMethod()> Public Function MyWebServiceFunction(_

             ByRef Parameter1 As Integer, _

             ByRef Parameter2 As Integer) As Integer

  1. When the project is built, it will create a XML Web service on the specified Web server, which exposes each method that has a WebMethod attribute.

  2. Information about the XML Web service—such as the WSDL file—can be obtained by browsing to the .asmx file for the class that implements the XML Web service: