asp.net session 14
TRANSCRIPT
-
7/27/2019 ASP.net Session 14
1/22
Slide 1 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
In this session, you will learn to:
Consume Web services in a Web application
Explain Asynchronous JavaScript and XML (AJAX) framework
Objectives
-
7/27/2019 ASP.net Session 14
2/22
Slide 2 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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.
Consuming Web Services in a Web Application
-
7/27/2019 ASP.net Session 14
3/22
Slide 3 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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.
Invoking Web Services
-
7/27/2019 ASP.net Session 14
4/22
Slide 4 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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 createsan 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.
Invoking Web Services (Contd.)
-
7/27/2019 ASP.net Session 14
5/22
Slide 5 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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.
Invoking Windows Communication Foundation Services
-
7/27/2019 ASP.net Session 14
6/22
Slide 6 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
The following figure shows the WCF architecture.
Invoking Windows Communication Foundation Services (Contd.)
-
7/27/2019 ASP.net Session 14
7/22Slide 7 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
The following set of APIs is unified in the WCF architecture:
ASP.NET Web Services (ASMX)
WSE
System.Messaging
Enterprise ServicesRemoting
The design goals for building WCF services are:
Unification
Interoperability
Service orientation
Invoking Windows Communication Foundation Services (Contd.)
-
7/27/2019 ASP.net Session 14
8/22Slide 8 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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.
Activity 9.2: Creating a Web Part that Uses a Web Service
-
7/27/2019 ASP.net Session 14
9/22Slide 9 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
Solution:
To solve the preceding problem, you need to perform the
following tasks:
1. Add the CurrencyConverter project to the solution.
2. Add a reference to the Web service.
3. Create a user control to consume the Web service.
4. Add the user control to the Portal page.
5. Test the application.
Activity 9.2: Creating a Web Part that Uses a Web Service (Contd.)
-
7/27/2019 ASP.net Session 14
10/22Slide 10 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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.
Activity 9.3: Creating a Web Part that Uses a WCF Service
-
7/27/2019 ASP.net Session 14
11/22Slide 11 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
Solution:
To solve the preceding problem, you need to perform the
following tasks:
1. Add the CurrencyConverter project to the solution.
2. Add a reference to the WCF service.
3. Create a user control to consume the WCF service.
4. Add the user control to the Portal page.
5. Test the application.
Activity 9.3: Creating a Web Part that Uses a WCF Service (Contd.)
-
7/27/2019 ASP.net Session 14
12/22Slide 12 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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 waitingfor a response from the server.
Enables partial updates in Web applications.
Explaining the AJAX Framework
-
7/27/2019 ASP.net Session 14
13/22Slide 13 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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
Understanding AJAX
-
7/27/2019 ASP.net Session 14
14/22Slide 14 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
The following figure illustrates the complete life cycle of an
AJAX-enabled Web page.
Working of an AJAX-Enabled Web Application
-
7/27/2019 ASP.net Session 14
15/22Slide 15 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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
Advantages of AJAX-Enabled Web Applications
-
7/27/2019 ASP.net Session 14
16/22Slide 16 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
Some of the limitations of AJAX-enabled Web applications
are:
Browser Integration
Dependency on JavaScript
Limitations of AJAX-Enabled Web Applications
-
7/27/2019 ASP.net Session 14
17/22
-
7/27/2019 ASP.net Session 14
18/22Slide 18 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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
Architecture of ASP.NET AJAX (Contd.)
-
7/27/2019 ASP.net Session 14
19/22
-
7/27/2019 ASP.net Session 14
20/22
-
7/27/2019 ASP.net Session 14
21/22Slide 21 of 22Ver. 1.0
Developing Web Applications Using ASP.NET
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 singleinfrastructure.
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 interferingwith the display and behavior of the existing page.
AJAX includes the following terms:
Asynchronous communication
JavaScript
XML
Summary
-
7/27/2019 ASP.net Session 14
22/22Slid 22 f 22
Developing Web Applications Using ASP.NET
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 IntegrationDependency on JavaScript
The ASP.NET AJAX architecture consists of the following
components:
Client-based Microsoft AJAX library
Server-based AJAX features for ASP.NET
Summary (Contd.)