Você está na página 1de 22

Developing Web Applications Using ASP.

NET
Objectives

In this session, you will learn to:


Consume Web services in a Web application Explain Asynchronous JavaScript and XML (AJAX) framework

Ver. 1.0

Slide 1 of 22

Developing Web Applications Using ASP.NET


Consuming Web Services in a Web Application

Web services are the application components that can be used by other Web applications. You can create a Web service and publish it on a Web server, thereby, making it available for other Web applications to use.

Ver. 1.0

Slide 2 of 22

Developing Web Applications Using ASP.NET


Invoking Web Services

A Web service:
Is a self-describing Web component that exposes its functionality to the consumers through open standards such as XML and Simple Object Access Protocol (SOAP). Is a widely used method for implementing Service-Oriented Architecture (SOA). Allows integration of applications developed in different languages and running on different platforms. Communicates by using a standard protocol called SOAP. SOAP defines a standard way of passing the XML-encoded data.

Developing ASP.NET Web services starts by creating an .asmx file and hosting it on a Web server, such as IIS. A Web service once hosted or published on the server can be consumed by any client.
Ver. 1.0

Slide 3 of 22

Developing Web Applications Using ASP.NET


Invoking Web Services (Contd.)

The client locates the service by adding a Web reference. This adds a proxy class on the client side, which exposes the methods, parameters, and return types of the methods contained in the Web service. After adding the proxy class, the client application creates an instance of the proxy class and accesses the methods provided by the Web service through the instance. The client requests are then handled by the proxy class. After processing the request, the response is also sent as a SOAP message to the proxy. The proxy then converts this SOAP message into method return value, which is returned to the client.

Ver. 1.0

Slide 4 of 22

Developing Web Applications Using ASP.NET


Invoking Windows Communication Foundation Services

In distributed computing, Web services along with various other technologies, such as COM+, .NET Remoting, Message Queues, and Web Service Enhancement (WSE) were used to provide a wide range of functionality. WCF:
Unifies features of such discreet technologies under one single framework. Provides a unified programming model used to build a secure, reliable, and robust Web service. Aims at providing encoding, hosting, messaging patterns, networking, security, and interoperability in a single infrastructure.

Ver. 1.0

Slide 5 of 22

Developing Web Applications Using ASP.NET


Invoking Windows Communication Foundation Services (Contd.)

The following figure shows the WCF architecture.

Ver. 1.0

Slide 6 of 22

Developing Web Applications Using ASP.NET


Invoking Windows Communication Foundation Services (Contd.)

The following set of APIs is unified in the WCF architecture:


ASP.NET Web Services (ASMX) WSE System.Messaging Enterprise Services Remoting

The design goals for building WCF services are:


Unification Interoperability Service orientation

Ver. 1.0

Slide 7 of 22

Developing Web Applications Using ASP.NET


Activity 9.2: Creating a Web Part that Uses a Web Service

Problem Statement:
You need to include a Web part that allows a user to convert currency values from Dollar to Euro in the Portal.aspx page of the MusicMania website. To implement this requirement, you are provided with a Web service called CurrencyConverter.

Ver. 1.0

Slide 8 of 22

Developing Web Applications Using ASP.NET


Activity 9.2: Creating a Web Part that Uses a Web Service (Contd.)

Solution:
To solve the preceding problem, you need to perform the following tasks:
1. 2. 3. 4. 5. Add the CurrencyConverter project to the solution. Add a reference to the Web service. Create a user control to consume the Web service. Add the user control to the Portal page. Test the application.

Ver. 1.0

Slide 9 of 22

Developing Web Applications Using ASP.NET


Activity 9.3: Creating a Web Part that Uses a WCF Service

Problem Statement:
In the Portal.aspx page of the MusicMania website, you need to include a Web part that allows a user to convert currency values from Dollar to Euro. To implement this requirement, you are provided with a WCF service called CurrencyConverter.

Ver. 1.0

Slide 10 of 22

Developing Web Applications Using ASP.NET


Activity 9.3: Creating a Web Part that Uses a WCF Service (Contd.)

Solution:
To solve the preceding problem, you need to perform the following tasks:
1. 2. 3. 4. 5. Add the CurrencyConverter project to the solution. Add a reference to the WCF service. Create a user control to consume the WCF service. Add the user control to the Portal page. Test the application.

Ver. 1.0

Slide 11 of 22

Developing Web Applications Using ASP.NET


Explaining the AJAX Framework

AJAX is a technology, which when implemented in Web applications makes the interaction between the client and the server asynchronous. AJAX implementation:
Allows users to interact with the Web application while waiting for a response from the server. Enables partial updates in Web applications.

Ver. 1.0

Slide 12 of 22

Developing Web Applications Using ASP.NET


Understanding AJAX

AJAX is a Web development technique that:


Is used for creating dynamically interactive applications. Enables Web applications to retrieve data from the server, asynchronously in the background, without interfering with the display and behavior of the existing page.

To understand the concept of AJAX, you need to understand the relevance of the following terms:
Asynchronous communication JavaScript XML

Ver. 1.0

Slide 13 of 22

Developing Web Applications Using ASP.NET


Working of an AJAX-Enabled Web Application

The following figure illustrates the complete life cycle of an AJAX-enabled Web page.

Ver. 1.0

Slide 14 of 22

Developing Web Applications Using ASP.NET


Advantages of AJAX-Enabled Web Applications

AJAX-enabled Web applications offer:


Quick response to a users request Asynchronous communication that allows a user to interact with the rest of the Web page while the application is processing the changed or updated parts of the Web page Auto-generated proxy classes that are used to call Web service methods from client script such as JavaScript Support for the widely used Web browsers such as Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari

Ver. 1.0

Slide 15 of 22

Developing Web Applications Using ASP.NET


Limitations of AJAX-Enabled Web Applications

Some of the limitations of AJAX-enabled Web applications are:


Browser Integration Dependency on JavaScript

Ver. 1.0

Slide 16 of 22

Developing Web Applications Using ASP.NET


Architecture of ASP.NET AJAX

The ASP.NET AJAX Web applications consist of client-side and server-side scripts. The following figure displays the ASP.NET AJAX architecture.

Ver. 1.0

Slide 17 of 22

Developing Web Applications Using ASP.NET


Architecture of ASP.NET AJAX (Contd.)

The preceding figure shows that the ASP.NET AJAX architecture consists of the following components:
Client-based Microsoft AJAX library Server-based AJAX features for ASP.NET

Ver. 1.0

Slide 18 of 22

Developing Web Applications Using ASP.NET


Architecture of ASP.NET AJAX (Contd.)

Client-based Microsoft AJAX library:


The ASP.NET AJAX client architecture provides features that enable you to create rich, intuitive, responsive, and interactive Web applications. This architecture includes the ASP.NET AJAX library that includes:
Components Browser compatibility Networking Core services

Ver. 1.0

Slide 19 of 22

Developing Web Applications Using ASP.NET


Architecture of ASP.NET AJAX (Contd.)

Server-based AJAX features for ASP.NET:


The ASP.NET AJAX server architecture provides the functionalities for the following server-based AJAX features:
Script support Web services Application services Server controls

Ver. 1.0

Slide 20 of 22

Developing Web Applications Using ASP.NET


Summary

In this session, you learned that:


A Web service is a self-describing Web component that exposes its functionality to the consumers through open standards such as XML SOAP. WCF aims at providing encoding, hosting, messaging patterns, networking, security, and interoperability in a single infrastructure. AJAX is a Web development technique that is used for creating dynamically interactive applications. AJAX enables Web applications to retrieve data from the server, asynchronously in the background, without interfering with the display and behavior of the existing page. AJAX includes the following terms:
Asynchronous communication JavaScript XML
Ver. 1.0

Slide 21 of 22

Developing Web Applications Using ASP.NET


Summary (Contd.)

The advantages offered by an AJAX-enabled Web application are:


Quick response to a users request less bandwidth usage. Allows a user to interact with the rest of the Web page while the application is processing the changed or updated parts of the Web page. Auto-generated proxy classes that are used to call Web service methods from client script such as JavaScript. Support for the widely used Web browsers such as Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari.

The limitations of AJAX-enabled Web applications are:


Browser Integration Dependency on JavaScript

The ASP.NET AJAX architecture consists of the following components:


Client-based Microsoft AJAX library Server-based AJAX features for ASP.NET
Ver. 1.0

Slide 22 of 22

Você também pode gostar