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:
- 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++.
- 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.
- 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.
Public Class MyWebServiceClass
- 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
- 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.
- 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: