In the previous installment of this article series, we examined the standards and technologies that make up Web services.
We discussed how Web services provide a distributed architecture by which one computer can invoke a method on another computer over some network, such as the Internet. This interaction is made possible by both the client and server agreeing on a set of standards and protocols for message delivery and message serialization. To briefly recap, Web services communicate over the Internet using the HTTP protocol. Messages are formatted according to the SOAP specification. SOAP messages are plain-text and XML formatted.
In the previous installment we focused solely on examining Web services from 30,000 feet, and did not bother to actually implement a Web service provider and consumer. In this article, we'll look at how to build a Web service using Visual Studio .NET. As we'll see, Visual Studio .NET makes it incredibly easy to build a Web service.
Creating a Web service is Visual Studio .NET is so easy it is almost frightening. Start by creating a new ASP.NET Web Service project in the programming language of your choice. (For this article series, I'll be focusing on C#, and will point out any differences between VB.NET and C# that are germane.) As the screenshot to the right shows, when adding a new Web service project you are asked to specify a location in the form of a folder on a Web server. Since Web services are accessed via HTTP, Web services typically are implemented as a file on a Web site. To invoke the Web service, a client will make an HTTP request to the Web service's URL, passing in the SOAP message in the HTTP POST body. For this reason, an ASP.NET Web Service project is created as a new folder on a Web server. The Web service(s) we create in this project will be files located in this folder.