Passing Data Over .NET Web Services Web Services is a powerful technology, even in its basic form. However, with .NET, you can easily couple Web Services with .NET's new data services to provide a powerful data delivery mechanism that works over the Web, making it possible to build distributed applications that work easily without a local data store. In this article, Rick describes various ways you can use Web Services and ADO.NET DataSets to pass data between client and server applications to build truly disconnected applications. Web Services is without a doubt the most talked about topic in .NET. A couple of issues ago, I introduced you to the basics of Web Services along with a number of new concepts about how you can pass different kinds of data over the wire. In this article, I'll focus on using .NET Web Services as a transport for data, allowing you to build a remote data service with relatively little code. I'll show a simple example that demonstrates using ADO.NET DataSets for creating a remote data connection for a Windows Form-based application. | " | DataUpdates over the Web with DataSets require very little code, because DataSets provide all the packaging necessary for transit, persistence and updating the data source.
| " |
.NET makes this type of functionality relatively easy by providing both the Web Service transport mechanism (SOAP and HTTP), as well the built-in serialization services in the form of XML for all of the data objects it provides. ADO.NET DataSets make this process very easy and allow you to easily create fully disconnected database applications that can access data over the Web using standard HTTP. In this article, I'll focus on the ADO.NET DataSet object as the data transfer object that is passed back and forth. .NET introduces ADO.NET as the primary data access mechanism to access data in traditional database tables and other non-relational data sources. As ADO did prior to .NET, ADO.NET aims to abstract data to the point that it doesn't matter what kind of data backend technology is accessed. ADO.NET provides the view to that data. ADO.NET is a monumental improvement over the functionality that ADO provided, in that it provides a cleaner object model and much more flexibility in how data is represented and is manipulated. It allows you to create an offline data view of multiple tables or data sources in a single object that contains both the data itself and meta-data describing the data in the DataSet. In addition, DataSets can directly create data tables (roughly the equivalent of an ADO recordset) from XML input without any additional conversion routines. ADO.NET uses XML as its native data format and the data stored in datasets is internally represented as XML. What this means is that you can easily pass data from non-.NET sources to a .NET application and have a DataSet accept it without having to manually parse it through an XMLDOM, SAX, or XmlTextReader parser. All of this comes for free as part of the .NET XML support and its significance really doesn't hit home until you have occasion to take advantage of this functionality. DataSets also intrinsically have the ability to take data offline. In fact, DataSets are always offline. They are disconnected views of data, meaning that you can pass the data around to other applications, make changes to it, then update the original data source with the changes. The DataSet manages the changes and can re-synchronize with the database as needed. This makes it possible to use DataSets fairly transparently as a remote data source or in an offline application. DataSets can handle both single record update functionality (using the request/response model) or the fully offline scenario where the data is pulled down as a big chunk, worked on and modified, and then eventually re-synchronized with the data source.  Figure 1: Remote data access with .NET is easy by using Web Services with DataSets used as parameters. .NET can handle all the details of persisting and restoring a full DataSet object over a Web Service, including the ability to merge changes into the database. This provides a powerful tool for building remote data services over the Web. | & | | 
By: Rick Strahl Rick Strahl is president of West Wind Technologies in Maui, Hawaii. The company specializes in Web and distributed application development and tools, with focus on Windows Server Products, .NET, Visual Studio, and Visual FoxPro. Rick is the author of West Wind Web Connection, West Wind Web Store, and West Wind HTML Help Builder. He’s also a C# MVP, a frequent contributor to magazines and books, a frequent speaker at international developer conferences, and the co-publisher of CoDe Magazine. For more information please visit his Web site at www.west-wind.com or contact Rick at rstrahl@west-wind.com.
rstrahl@west-wind.com | Fast Facts | | .NET Web Services can make short work of creating data services over the Web, using the new features of ADO.NET. Rick shows you, step by step, how to design your services to make your data available for easy consumption. | |
|