Limitations of Web Services Summary

340

7.5 Web-Service Discovery

Up to this point, we have assumed that the client of a web service knows where to find that web services WSDL document. This may not always be the case. For example, consider a client application that runs on a portable device. Its purpose is to make a reservation on the users behalf at the nearest hotel meeting the users preset price and service guidelines. Before the client application can communicate with a hotels reservation web service, the client must have a way to discover that the service is even there. This is the purpose of web-service directories. Web-service directories provide a way for clients to find web services that perform a certain task or a certain kind of task. They are like the yellow pages in a telephone directory, in which businesses are listed according to the product or service they provide. Standards are just now being developed for web-service directories. One strong contender is called Universal Description, Discovery, and Integration UDDI. Information about this standard and the implementations that currently exist can be found at ht t p: w w w .uddi.or g . You may also have heard of DISCO files. DISCO is short for discovery. DISCO is a Microsoft- exclusive specification for encoding the addresses of multiple WSDL documents into a single XML document. DISCO doesnt have directory capabilities and so is falling into disuse as UDDI grows.

7.6 Limitations of Web Services

The ASP.NET framework makes it so easy to expose and consume web services that its easy to forget about the communication layer between the client and server. Because web services are built on the SOAP protocol, their capabilities are limited to the capabilities of SOAP. The most important points to remember are: No callback mechanism For a web service to call back to a client, the client has to handle incoming HTTP requests. Virtually no client systems are configured this way, so callbacks generally are not an option. If a callback system is absolutely required, it could be faked by writing methods in the client and server allowing the client component to periodically poll the server to determine if events have occurred. No transactions across the Web The SOAP protocol currently does not provide any transaction support. A web-service method can begin a new transaction, and local resources will enlist on that transaction, but a web service cant enlist on an existing transaction. Exceptions are returned as SOAP faults When there is some error in processing a web-method call, the web service responds with a SOAP fault. If the client of the web service is implemented on the .NET platform, the client receives a SoapException exception defined in the System.Web.Services.Protocols namespace, even if both the client and server are using .NET. Put another way, even if both client and server are running on .NET, exceptions thrown on the server arent raised as the same exception on the client. Performance is an issue There is overhead associated with representing function calls as XML. This overhead is a necessary evil when communicating over the Internet across network firewalls. However, web services are not a good choice for cross-component communication when the components are running on the same machine or even on different machines on the same LAN. Web services provide no benefit in these scenarios. 341

7.7 Summary

Web services are a new, industry-standard mechanism for connecting software components across the Internet. This mechanism is based on HTTP, XML, and SOAP—all widely accepted standards. The .NET Framework provides support for developers of web services and web-service clients, making it just as easy to expose and consume web services as it is to write and use a simple class that exposes methods. 342 343

Chapter 8. ADO.NET: Developing Database Applications

Many software applications benefit from storing their data in database management systems. A database management system is a software component that performs the task of storing and retrieving large amounts of data. Examples of database management systems are Microsoft SQL Server and Oracle Corporations Oracle. Microsoft SQL Server and Microsoft Access both include a sample database called Northwind. The Northwind database is used in the examples throughout this chapter. All examples in this chapter assume that the following declaration appears in the same file as the code: Imports System.Data Examples that use SQL Server also assume this declaration: Imports System.Data.SqlClient and examples that use Access assume this declaration: Imports System.Data.OleDb

8.1 A Brief History of Universal Data Access

Database management systems provide APIs that allow application programmers to create and access databases. The set of APIs that each manufacturers system supplies is unique to that manufacturer. Microsoft has long recognized that it is inefficient and error prone for an applications programmer to attempt to master and use all the APIs for the various available database management systems. Whats more, if a new database management system is released, an existing application cant make use of it without being rewritten to understand the new APIs. What is needed is a common database API. Microsofts previous steps in this direction included Open Database Connectivity ODBC, OLE DB, and ADO not to be confused with ADO.NET. Microsoft has made improvements with each new technology. With .NET, Microsoft has released a new mechanism for accessing data: ADO.NET. The name is a carryover from Microsofts ADO ActiveX Data Objects technology, but it no longer stands for ActiveX Data Objects—its just ADO.NET. To avoid confusion, I will refer to ADO.NET as ADO.NET and to ADO as classic ADO. If youre familiar with classic ADO, be careful—ADO.NET is not a descendant, its a new technology. In order to support the Internet evolution, ADO.NET is highly focused on disconnected data and on the ability for anything to be a source of data. While you will find many concepts in ADO.NET to be similar to concepts in classic ADO, it is not the same.

8.2 Managed Providers

When speaking of data access, its useful to distinguish between providers of data and consumers of data. A data provider encapsulates data and provides access to it in a generic way. The data itself can