ASP.NET and Web Services
The ASP.NET framework simplifies development of web services. All the low-level work, such as packaging and unpackaging data in XML format and utilizing HTTP protocol to transport the web messages between distributed components, are done by the framework. This allows the developers to focus on the application logic.
The .NET Framework uses
asmx as the default file
extension for web services, as opposed to
Web Forms and
ascx for web controls.
The WebService Directive
files start with the
directive that instructs ASP.NET on how to compile the code, as well
as the main class name. The WebService directive has the following
Specifies the language in which the code was written. This instructs the ASP.NET framework to use the appropriate compiler to build your web service. Use
vbfor Visual Basic and
c#for C#. As other languages emerge, obviously you can specify other languages.
Specifies the main class, which exposes web methods. The ASP.NET framework instantiates this class in order to serve the web methods to the clients.
Specifies the source file for your code, which allows for complete code/ASP separation.
You can easily create a simple web service similar to the following
<%@ WebService Language="VB" Class="MyClass" %>Public Class MyClass Public Function
<WebMethod( )>Add(a as integer, b as integer) as integer Return a + b End function End class
If you prefer to separate your ...