Use Data in XML Web servicesThis sample shows how DataSets, a powerful new XML-based way to represent disconnected data, can be returned from a Web Service method. This is an extremely powerful use of XML Web services, as DataSets can store complex information and relationships in an intelligent structure. By exposing DataSets through a service, you can limit the database connections your data server is experiencing.The method GetTitleAuthors connects to a database and issues two SQL statements: one that returns a list of authors, and another that returns a list of book titles. It places both result sets into a single DataSet called ds, and returns this DataSet. The method PutTitleAuthors illustrates a Web Service method that takes a DataSet as a parameter, returning an integer that represents the number of rows received in the "Authors" table of the DataSet. Although the implementation of this method is somewhat simplistic, this method could also intelligently merge the passed data with the database server.
The client application for this XML Web service calls GetTitleAuthors and binds the Authors table to a DataGrid control, as you've seen in previous examples. To illustrate the PutTitleAuthors method, the client removes three rows of data from the DataSet before calling this method, printing out the number of rows received by the service.
|