Chapter 2. The AJAX Application Server: Service Orientation and the Windows Communication Foundation

After completing this chapter, you will

  • Understand the principles of service orientation and how to incorporate service orientation in an application platform for AJAX components.

  • Understand the fundamentals of Windows Communication Foundation (WCF) endpoints, bindings, and behaviors.

  • Understand how to implement contract-based services with WCF.

  • Understand how to deploy WCF services to an ASP.NET application.

In Chapter 1, you learned about foundational AJAX runtime components using JavaScript, ASP.NET AJAX, basic AJAX Web requests, and simple service endpoints in Windows Communication Foundation (WCF). You also learned about some of the benefits of service orientation and of separating an end-user application from back-end architecture. In this chapter we will look at service orientation and back-end architecture in more detail. You’ll also learn how to implement an application as a service-oriented Web application. We’ll use WCF services hosted in an ASP.NET application, and these services will be the core application platform for the AJAX application.

The Benefits of WCF as the AJAX Services Platform

WCF serves as the plumbing for AJAX-enabled Web services and provides a unified programming model for communication between servers and clients. Although WCF is a flexible runtime that can be hosted in many environments other than ASP.NET, including services hosted over TCP/IP or other LAN protocols, we’ll look at WCF purely as a Web services platform. The examples I describe in this chapter and throughout the book run in Internet Information Services (IIS) under an ASP.NET hosting application.

By using a service-based architecture you gain tremendous potential for the reuse of an AJAX application, and you can free your application from the monolithic page-based development model that is typical of pre-AJAX Web applications. As a side benefit, an investment in the service platform architecture lets you use the same Web services for remote clients. Whether you decide to expose services to remote applications or use tightly coupled services as the basis for your AJAX application, the service-based AJAX architecture pattern enables reuse, rapid development, and the greatest flexibility for your AJAX application by separating it from the service platform. And because services are not tied to the end-user application, the service application tends to have a much longer lifetime as a product than the end-user application does. You can also add new services and platform enhancements without having to refactor the client application. You can upgrade the back-end platform with new data access technologies, such as enhancements to Language Integrated Query (LINQ) or Microsoft SQL Server, without affecting the service interfaces. Figure 2-1 highlights the role of WCF in the AJAX application architecture.

WCF is used to implement the service infrastructure for an AJAX application.

Figure 2-1. WCF is used to implement the service infrastructure for an AJAX application.

While I primarily discuss using WCF for service implementations, WCF is just one way to implement services. In place of WCF you could use ASMX Web services or ASP.NET with HTTP handlers to implement XML endpoints, as I’ll discuss at the end of this chapter. There is no right or wrong way to implement the service layer, but we will mainly use the .NET 3.5 Framework implementation of WCF because of its rich support for service orientation and its ability to separate the Web programming model from the service implementation.

More Information

More Information

This book is not meant to be a comprehensive reference about WCF. I cover enough about WCF to show how to implement the AJAX back end. For a comprehensive reference on WCF, I recommend Justin Smith’s book Inside Windows Communication Foundation (Microsoft Press, 2007).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset