Today you learned about a new way to deliver applications: over the Internet as Web services. Web services are an integral part of ASP.NET, and they use the XML and HTTP standards to allow components to talk to each other over the Web.
Web services work in three stages: discovery, a description of services, and command communication. Discovery is an optional process that allows clients to find out about a Web service; specifically, where it's located. The service description, provided in an XML-based standard called the Service Description Language, tells clients which methods are available to use remotely and which types of data are expected and returned. Finally, the service and client use these descriptions to send commands to the server and data back to the client.
Three protocols are used for Web service communication: Http-Get, Http-Post, and the Simple Object Access Protocol (SOAP). The first two allow the communication of simple name/value pairs of data. The last one, based on XML, is able to deliver much wider-ranging types of data.
You build Web services in .asmx files, just as you do with business objects. The difference is that you inherit from the WebService class, and all methods that will be exposed as services must use the WebMethods attribute. At a minimum, the .asmx file must contain the following:
<%@ WebService docEmphasis">class" %>
The WebService directive tells ASP.NET that this file contains or references a class that should be exposed as a Web service. The class attribute is the name of the class to expose. This class can be either contained within the .asmx file or separately compiled as a business object.
You enable discovery by using .disco files, which are XML documents that contain links to Web service descriptions. These files can be built manually, to define a specific service, or dynamically, to define a group of services available on a server.
Finally, you can view the .asmx files through the browser to see an HTML description page, which describes the methods available and allows you to test the functionality directly through Http-Post. You also can see the service description as XML from the .asmx page.
After today, you should be comfortable developing Web services and deploying them on your servers. Tomorrow's lesson will continue the discussion of Web services, and you'll learn how to use them from the client's side.