Chapter 55: Web Services with ASP.NET
What’s In This Chapter
-
How SOAP and WSDL are used by web services
-
Exposing and consuming web services
-
The use of web services
-
Exchanging data by using SOAP headers
Web services are a way of performing remote method calls over HTTP that can make use of Simple Object Access Protocol (SOAP). In the past, this issue was fraught with difficulty, as anyone who has any DCOM (Distributed COM) experience knows. Using older technologies, the act of instantiating an object on a remote server, calling a method, and obtaining the result, is far from simple, and the necessary configuration is even trickier.
SOAP simplifies matters immensely. This technology is an XML-based standard that details how method calls can be made over HTTP in a reproducible manner. A remote SOAP server is capable of understanding these calls and performing all the hard work for you, such as instantiating the required object, making the call, and returning a SOAP-formatted response to the client.
The .NET Framework makes it very easy for you to do this. As with ASP.NET, you are able to use the full array of C# and .NET techniques on the server, but (perhaps more importantly) the simple consumption of web services can be achieved from any platform with HTTP access to the server. In other words, it is conceivable that Linux code could, for example, use ASP.NET web services, or even Internet-enabled fridges. To quote a real-world example, in the past I have had great success combining ASP.NET web services with Macromedia Flash to create data-enabled flash content.
In addition, web services can be completely described using Web Service Description Language (WSDL), allowing the dynamic discovery of web services at runtime. WSDL provides descriptions of all methods (along with the types required to call them) using XML with XML schemas. A wide variety of types are available to web services, which range from simple primitive types to full DataSet objects; this makes it possible to marshal full in-memory databases to a client. This can result in a dramatic reduction in load on a database server.
NOTE: Note that this chapter deals with ASP.NET web services and not WCF web services, which are a more recent addition to .NET. ASP.NET web services are simpler to use and perfectly adequate for most situations, while Windows Communication Foundation (WCF) web services encompass all of ASP.NET web service functionality and add additional capabilities. For more information on WCF, see Chapter 43.
This article is excerpted from chapter 55 "Web Services with ASP.NET" of the book "Professional C# 4 and .NET 4" by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner (ISBN: 978-0-470-50225-9, Wrox, 2010, Copyright Wiley Publishing Inc.)

