a - To Parent Directory
Download
Report
Transcript a - To Parent Directory
Chapter 9
Web Applications
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
Chapter Objectives - 1
• Explain the functions of the server and the
client in Web programming
• Create a Web Form and run it in a browser
• Describe the differences among the various
types of Web controls and the relationship of
Web controls to controls used on Windows
forms
• Understand the event structure required for
Web programs
• Design a Web Form using tables
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-2
Chapter Objectives - 2
• Control the styles used on Web pages using
cascading style sheets (CSS)
• Create multiple pages in a Web application
• Navigate using the HyperLink control and the
Server object
• Validate Web input using the validator controls
• Use state management to preserve values in
variables
• Use AJAX to update a portion of a Web page
• Define ASP.NET, XML, WSDL, and SOAP
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-3
What Are Active Server Pages?
• Web server based technology, a tool for building
Web applications
• ASP (Not Application Service Provider)
• A powerful framework that provides dynamic
generation of Web pages
• Facilitates access to information from other
sources such as databases
• Requires Web server that has ASP installed as an
extension
• Combination of HTML and executable codes that
allows programming logic to be embedded within a
Web page
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
4
9-4
The Original Web Model
User’s Browser
Web Server
HTTP REQUEST
Web Page
(.htm)
HTML
McGraw-Hill
AIU ITP 665
- Servlets
© 2010 The McGraw-Hill
Companies,
Inc. All rights reserved.
5
9-5
The Dynamic Web Model
User’s Browser
Web Server
HTTP REQUEST
Engine:
reads
user’s
request ;
generates
Web page
HTML
The Web page to be delivered to the client is generated “ on the fly “
as the result of the server-side processing of the “page draft” – the
Active Server Page, and the result of this processing will be delivered
to the client
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-6
Why Build Web Pages Dynamically?
• The Web page is based on data submitted by the user
– E.g., results page from search engines and orderconfirmation pages at on-line stores
• The Web page is derived from data that changes frequently
– E.g., a weather report or news headlines page
• The Web page uses information from databases or other
server-side sources
– E.g., an e-commerce site could use a servlet to build a Web
page that lists the current price and availability of each item
that is for sale.
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
7
9-7
ASP’s Job – Communicate with
Web Client
• Read explicit data sent by client (form data)
• Read implicit data sent by client
(request headers)
• Generate the results
• Send the explicit data back to client (HTML)
• Send the implicit data to client
(status codes and response headers)
McGraw-Hill
8 ?
© 2010
McGraw-Hill
Companies,
All rights
reserved.
Can
aThe
client
sent any
data Inc.
to the
server
? Why
9-8
First Tool to make Web Dynamic
was : CGI
• CGI (Common Gateway Interface) :
– an extension to Web server application
– CGI allowed Web sites to dynamically create Web
pages from a program running on a server and
typically written in C or a scripting language such as
Perl
– CGI added functionality to the Web
– CGI programs often exhausted memory space on
Windows computers
– These shortcomings eventually led to Active Server
Pages, or ASP from Microsoft, and Servlets and JSP
from Sun used now
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9
9-9
What is an Active Server Page ?
a server-side component
•Runs (being processed by a ASP container (IIS)
•Hosted on the IIS Web server
ASP can be used to
•Create HTML pages on the fly
•Perform CGI related task to facilitate HTTP
communications between a client and a server
•Access any business classes at the server
• Use distributed objects , access databases, email
systems, legacy systems
•Perform many other services
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
10
9-10
Scripting
Client Side vs. Server Side
• Client side scripts are embedded in a Web
page and interpreted by the browser
• Server side codes are embedded in a Web
page ( or stand behind it ) and interpreted
by the Web server (the browser never sees
them)
• Core language plus environment’s objects
provide a powerful tool for creating Web
applications
McGraw-Hill
AIU ITP 665
- Servlets
© 2010 The McGraw-Hill
Companies,
Inc. All rights reserved.
11
9-11
ASP.NET
• Main ASP.NET applications
1. Web Forms
•
Used to process forms and develop crossbrowser applications
•
Uses .aspx file extension
2. Web Services
McGraw-Hill
•
Other applications can interact with your program
•
Uses .asmx file extension
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
12
9-12
ASP.NET
• ASP.NET 3.5 is the latest Web programming
technology from Microsoft
• ASP.NET provides libraries, controls, and
programming support for programs that:
–
–
–
–
–
Interact with the user
Maintain state
Render controls
Display data
Generate appropriate HTML
• Write object-oriented, event-driven Web
applications using C# and ASP.NET
McGraw-Hill
is ASP.NET
application
deployed
©Where
2010 The McGraw-Hill
Companies,
Inc. All rights
reserved.
?
9-13
C# and Web Programming
• Web Forms are used to create the user
interface for Web applications
• A Web Form displays as a document in a
browser
• You can create documents that display on
mobile devices, such as cell phones and
PDAs (using the Standard Edition and
above)
McGraw-Hill
Where
is the
Web Form
hostedInc.
? All
Where
is it processed ?
© 2010
The McGraw-Hill
Companies,
rights reserved.
9-14
C# and ASP.NET
• Each Web Form has two distinct pieces
– HTML and instructions needed to render the page
– C# code
• A Web Form generates two files:
– .aspx extension for the HTML
– .aspx.cs extension for the C# code
• Holds the logic to respond to events
• Called the "code behind" file
• C# code is not compiled into an .exe file, it is
compiled into a dynamic link library (dll) file
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-15
Web Servers
• To develop Web applications
– Use a remote Web server
– Make your local machine a Web server
• Visual Studio Web Server
– Installs automatically with Visual Web Developer or
Visual Studio
– Simplifies development, testing, and debugging
– Use IDE tools to transfer application to an IIS Web server
after development to share with others
• Internet Information Services (IIS)
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-16
Web Clients
• Browsers display pages written in a markup
language such as HTML or XHTML
• Pages may also contain program logic
– Script
• JavaScript, VBScript, JScript
– Java applets
• Programming for a network intranet
– Users’ browser is known
• Programming for the Internet
– Test and check output on multiple browsers
• Internet Explorer, Mozilla FireFox and Opera
McGraw-Hill
Is there
difference
between
XHTML ?
© 2010any
The McGraw-Hill
Companies,
Inc. HTML
All rights and
reserved.
9-17
Web Pages
• Web pages are stateless
– The page does not store any information about its
contents from one invocation to the next
• Techniques for working around the stateless
limitation
– Storing cookies on the local machine
– Sending state information to the server as part of the
page's address, called the uniform resource locator
(URL)
• The server can send the state information back with the next
version of the page
McGraw-Hill
WhatCompanies,
is a cookie
© 2010 The McGraw-Hill
Inc. All?rights reserved.
9-18
Types of Web Sites
• Web applications are referred to as Web
sites in VS 2008
• Four types of
Web sites :
1.File System
2.Local IIS
3.FTP site
4.Remote site
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-19
File System Web Sites
• Store Web pages and associated files
in any folder on the local computer or
on the network
• Does not expose the computer to security
vulnerabilities
• Does not require administrative rights to
create and debug a Web project
• Runs on Home Edition of Vista or XP
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-20
IIS Web Sites
• IIS on a local computer hosts a Web
server that must be secured
• Requires administrative rights on the
computer to create IIS Web projects
• By default files are stored in
C:\inetpub\wwwroot folder
– A virtual IIS directory can be created to store
a Web site
McGraw-Hill
© 2010 What
The McGraw-Hill
Companies,
Inc. All rights
is a vituall
IIS directory
?reserved.
9-21
Remote Sites and FTP Sites
• Administrative rights on the host computer
must be granted to do development on a
remote Web server
• FTP cannot be used to create a new Web
site
• A previously created FTP Web site can
be opened in Visual Studio :
– you can do development on a remote
server
McGraw-Hill
Azure
platform
– have
look
it
©MS
2010 The
McGraw-Hill
Companies,
Inc.aAll
rightswhat
reserved.
is …
9-22
Creating a Web Site
• Select New Web Site from the File menu
• In the New Web Site dialog box, select the
template, location, and language
• Give the Web
site a name
by appending
the name to
the location
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-23
Web Page Files
• A new Web site automatically contains one Web
page, Default.aspx
– Visual representation of the page (HTML tags)
• A second file, Default.aspx.cs, holds the C#
code for the page
• ASP.NET has a second model for Web
applications—single-file model
– Stores all HTML, control definitions, and code in one
single file
• The textbook teaches the code-separation
model that uses two separate files
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-24
Web Forms in the Visual Studio IDE
• Differences between a Web application and a
Windows Forms application
– Web Form (page or document) not a Windows
Form
– Toolbar
– List of files in the Solution Explorer
– Toolbox has different controls
• Properties and events different than controls that have a
Windows counterpart
• Views available in the IDE are Design, Source
(HTML or ASP.NET) or a Split window
McGraw-Hill
© 2010do
The a
McGraw-Hill
Companies,
Inc. All
rightsForm
reserved.differ ?
How
Windows
Form and
Web
9-25
Viewing the HTML Code
• Three tabs at bottom of Web Form
– Design
– Split
• Splits the Document window horizontally to see
both the design and source
– Source
• Static HTML code
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-26
Controls - 1
• Several types of controls available for Web
Forms
– Standard (ASP.NET server controls)—Richest and
most powerful controls provided by ASP.NET and
.NET framework
– Data—Display database data
– Validation—Validate user input before it is sent to
server
– Navigation—Includes the Menu control
– Login—Login controls and wizards
– WebParts—Change the appearance and behavior of
the interface from the browser
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-27
Controls - 2
– AJAX Extensions – Provide for faster Web
page loading and richer interfaces
– HTML – Standard elements that operate only
on the client
• HTML controls pass to and from the server as
static text
– Others – Depending on version of VS, other
sections may be available (i.e. Reporting)
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-28
Controls - 3
• In Design view, client-side HTML controls
and ASP server controls are different
• Popup DataTips identify the type of
control and its ID (Name)
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-29
Event Handling
• Write C# code for events of Web controls in
the same way as for Windows controls
• Events may occur on either the client or
server
• The process of capturing an event, sending it
to the server, and executing the required
methods is all done automatically
• Events of Web Forms and controls are different
than for Windows Forms
– Examples
• Page.Load versus Form.Load
• Button control has much shorter list of events for a Web
Form versus a Windows From
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-30
One more time : Page Files
• Web application files differ greatly from a
Windows application
• aspx file
– Holds specifications for the user interface
used by the server to render pages
• aspx.cs file
– Code-behind file for the aspx file
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-31
Testing in Other Browsers
• To test in another browser, in the
Solution Explorer:
– Right-click on the project name
– Select Browse With
– Select from browsers installed on the
computer
McGraw-Hill
Why would you need/like to test in another
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
browser ?
9-32
Laying Out Web Forms
• Factors that will affect the layout of page
– Browsers
– Screen sizes
– Screen resolutions
• ASP.NET generates appropriate HTML to
render the page in various browsers but
cannot be aware of the screen size,
resolution, or window size on the target
machine
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-33
Using Tables for Layout
• HTML tables contain
rows and columns and
allow control over
placement of elements
on a Web page
• Add controls and text to
the table cells to align
the columns
• A table is an HTML
control, which requires
no server-side
programming
McGraw-Hill
Does
it mean that you need to use tables on every
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
page ?
9-34
Placing Controls or
Text in a Table - 1
• Add controls to any table cell or type
text in a cell during design time
– To refer to the text in a cell at run time, add a
label and give it an ID or type text directly into
the cell
– Merge cells to allow room for a title or a larger
image
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-35
Placing Controls or
Text in a Table - 2
• Table borders show at design time but
not at run time
McGraw-Hill
Hoe
tables
seen at
run reserved.
time ?
© 2010to
Themake
McGraw-Hill
Companies,
Inc.the
All rights
9-36
Absolute Positioning
• Places controls in a specific X and Y position
– Controls may not show up if user has set browser
window to small size
– Controls may overlap if the user has selected a large
font size for the browser window
• Controls can be dragged using the white tab at
the top of a selected control
• Controls remain in the same position relative to
the Web page
McGraw-Hill
the above
: does
© 2010As
Thefrom
McGraw-Hill
Companies,
Inc. Allabsolute
rights reserved.
positioning have a value ?
9-37
Including Images on Web Pages - 1
• Use the Image control to add graphics to a
Web page
– Concept is similar to the PictureBox on Windows
Forms, but the graphic file is connected differently
due to the nature of Web applications
• Each Image control has an ImageUrl property
that specifies the location of the graphic file
– Best to first copy the graphic into the Web site
folder - WHY ?
• Add an Image control to a cell in a table or
directly on a Web page
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-38
Including Images on Web Pages - 2
• Web page table
has three rows
and three
columns
– Image and
company title
are in first row,
textbox is in
second row,
hyperlink is in
last row
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-39
Cascading Style Sheets
• New tools for using styles in Web
applications are called Expression Web
– Expands, enhances and simplifies using
cascading style sheets (CSS)
• Use CSS to create, modify and apply
styles to single elements on a page, an
entire page, all pages, or all applications of
an organization
McGraw-Hill
do we
mean Inc.
byAll
style
© 2010 TheWhat
McGraw-Hill
Companies,
rights?reserved.
9-40
Using Styles - 1
• Styles are rules that specify page layout,
position, font, color, alignment, margins,
borders, background and bullet and numbering
formats
• Create and apply new styles within a page
• Attach an external .css file to apply styles
• Save styles to an external .css file for use on
other pages or Web sites
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-41
Using Styles - 2
• Styles can be defined in several locations
– Web page – inline style
• For elements that appear only once on a page
– style section – page style
• For elements that may be used in more than one
location on a page
– external style sheet - .css file
• For elements that may appear on more than one
page or in multiple Web sites
McGraw-Hill
How
to McGraw-Hill
add external
CSSInc.toAllarights
Web
project ?
© 2010 The
Companies,
reserved.
9-42
Using Styles - 3
• “Cascading” refers to the order of precedence of
the style rules
• For example
– Style sheet (global) sets font, color, size, alignment
– Local (page-defined) style for the color and size
takes precedence (font and alignment still in effect
from style sheet)
– Inline (more local) style for the size takes
precedence over local and style sheet (color from
local and font and alignment from style sheet remain)
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-43
Types of Styles
• Several new tools are available to define,
apply, modify and change the location of
styles
– Apply Styles window : see Styles menu
– Manage Styles window : View -> “Manage
Styles”
– Use the icons in the CSS Style Types table to
identify the various types of styles
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-44
Defining Styles
• Define a new style in the New Style
dialog box
• Choose the category and make settings
– For example
• Font
• Block
– Text-align, text-indent, vertical align
• List
– Bullet and numbering attributes
• Table
– Borders and spacing
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-45
Managing Styles
• In the Manage Styles Window, preview
each style
– Drag styles from one category to another to
change the location of the style definition
• A style created in the current page can be moved
to a .css file to allow its use in other pages
• In the CSS Properties window see the
settings for a given style
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-46
Navigating Web Pages
• ASP.NET provides several techniques to
navigate from one Web page to another
• Easiest form of navigation is to use a
HyperLink control
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-47
Linear and Hypertext Documents
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-48
Using Hyperlinks
• Add a HyperLink control to allow the user
to navigate to another page or another site
• Set properties of the HyperLink control
– Text—Text to display for the user
– NavigateUrl—Specify the URL to which to
navigate
• For another Web site, type the Web address (URL)
• For another page in the application, use the Select
URL dialog box and select the page from a list
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-49
Adding a Second Web Page
•
•
•
•
•
Add a new web form to the project
Add controls to the new page
Add a HyperLink to the Main Page
Set the Start Page
Run the application, test the links
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-50
Transferring Pages in Code
• At times a hyperlink cannot be used
because some other action in code needs
to be performed prior to the transfer
• Transfer to another page in code
– Use the Server.Transfer method
Server.Transfer (“Offer.aspx”);
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-51
Using the Validator Controls - 1
• ASP.NET provides several validator controls
that can automatically validate input
– Add a validator control
– Attach it to an input control (such as a text box)
– Set the error message to display
• At run time, when the user inputs data, the error
message displays if the validation rule is violated
• Validator controls run on the client-side
McGraw-Hill
How did they do without MS Validator controls ?
it McGraw-Hill
be done Companies,
in code Inc.
? What
© Can
2010 The
All rightslanguage?
reserved.
9-52
Using the Validator Controls - 2
• A blank entry passes the validation for
each of the controls except the
RequiredFieldValidator
– To ensure a field is not blank and it passes a
range check attach both a RangeValidator
and a RequiredFieldValidator to the field
• Enter a complete message in the
ErrorMessage property or set the property
to an asterisk
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-53
Using the Validator Controls - 3
• Validator Controls
RequiredFieldValidator
CompareValidator
RangeValidator
RegularExpressionValidator
ValidationSummary
McGraw-Hill
Requires that the user enter something into the
field
Compares the value in the field to the value in
another control or to a constant. Also can be
used to verify that the input value can be
converted to the correct data type
Requires that the input value falls in the specified
range
Validates against a regular expression, similar to
the mask in a masked text box
Displays a summary of all of the messages from
the validator controls
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-54
Maintaining State
• Web pages hold static data
• Each time a page is displayed or
redisplayed it is a fresh copy
• Each time the page is posted back to
the server a new copy of the program is
loaded
• Steps must be taken to maintain the state
of the page
– Otherwise the values of variables and controls
on the page will be lost in every postback
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-55
Retaining the Contents of Controls
• ASP.NET can retain and redisplay control
contents
• Web controls have an EnableViewState
property
– Set to true by default
– Indicates to the server to send the
control’s contents back with the page
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-56
Retaining the Values of Variables - 1
• Local variables work the same in a Web or
Windows application
• Class-level variables are lost unless
steps are taken to save them
• Store the value of a class-level variable in
a control on a Web page
– EnableViewState property holds the value
during postback
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-57
Retaining the Values of Variables - 2
• Set up a control with its Visible property set to
false or use the HiddenField control
• Assign the class-level variable to the invisible
control
– For a hidden field, use the (string) Value property
// Declare a class level variable.
private decimal discountTotalDecimal;
protected void submitButton_Click(object sender, EventArgs e)
{
// . . . Calculations omitted.
discountHiddenField.Value = discountTotalDecimal.ToString();
}
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-58
Checking for Postback
• The Page_Load event occurs many times
(during each postback) in a Web application
• IsPostBack property is set to false for an initial
page load and true for all page loads following
the first
• Test for IsPostBack == false to perform
initialization tasks
• Test for IsPostBack == true to perform tasks
only on postback
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-59
Passing Values to a Second Page
• A HiddenField control maintains the value
of a class-level variable for a single page
• Send information to a second page
– Use the Session variable technique to pass
data between pages
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-60
Using a Session Variable - 1
• One instance of the Session object
exists for each user of an application
– Use to store information about the user on the
server
– Each time a user accesses an application, a
Session object is created with a unique
SessionID
– Session values are maintained as long as the
session exists
• Sessions can time out, terminate or users can
logout
McGraw-Hill
Can you
get to the same session if you have closed a
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
bropwser and opened it again ?
9-61
Using a Session Variable - 2
• Drawbacks to session objects
– Information is stored on server
• Large amounts of data for multiple users can
bog down the server
– Web sites split server loads among several
systems (Web Farm)
• State information might be on a different server
than where the postback originates
– .NET handles this problem by specifying the name of the
machine that stores the session values in the Web.config
file
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-62
Using a Session Variable - 3
• Use the Contents collection of the
Session object to store values in code
• Each item in the collection is a key/value
pair
– Make up a name (the key) and assign a value
• Clear all session variables by using the
Session.Clear method
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-63
AJAX -1
• Create interactive Web applications with
Asynchronous JavaScript and XML (AJAX)
• AJAX allows reloading of only a portion
of a Web page on each postback
– Only the portion of a page that changes is
downloaded and rendered
• Dramatically increases loading speed
• AJAX is an open and cross-platform
technology
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-64
AJAX - 2
• AJAX pages must include a
ScriptManager component (in the toolbox
under AJAX Extensions)
– Add other controls such as the UpdatePanel
• A container for other controls
– Placing controls inside an UpdatePanel
determines which portion of the page updates
on a postback
• The area outside the UpdatePanel remains
unchanged
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-65
Some Web Acronyms - 1
• XML Extensible Markup Language.
– This popular tag-based notation is used to define data
and their format and transmit the data over the Web.
XML is entirely text based, does not follow any one
manufacturer’s specifications, and can pass through
firewalls.
• SOAP Simple Object Access Protocol.
– An XML-based protocol for exchanging component
information among distributed systems of many
different types. Since it is based on XML, its
messages can pass through network firewalls.
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-66
Some Web Acronyms - 2
• HTTP HyperText Transfer Protocol.
– The protocol used to send and receive Web pages
over the Internet using standardized request and
response messages.
• Web Service
– Code in classes used to provide middle-tier services
over the Internet.
• WSDL Web Services Description Language.
– An XML document using specific syntax that defines
how a Web service behaves and how clients interact
with the service.
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-67
What do you see here ?
Happy New
Year!
Happy New Year !
Happy New Year !
Happy
New Year
Happy
New
Year
Happy New Year!
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-68
When Communicating
Information/Data:
•
•
•
•
•
Information/data content
Language / media of presentation
Form of presentation : phone,
TV, Web page, chat, . . .
XML :
an attempt to filter out “pure
information/data”
separate information content and its
presentation
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-69
XML – eXtensible Markup Language
What is it?
•
– World Wide Web Consortium (W3C specification)
– Describes semantic structure of text documents
– Descendant of Standardized General Markup
Language (SGML)
• Complex metalanguage used in technical documentation
– Extension of Hypertext Markup Language (HTML)
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-70
XML code segment
<message>
<to>[email protected]</to>
<from>[email protected]</from>
<subject>Sample of an XML file
</subject>
<text> XML is cool </text>
</message>
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-71
XML – Characteristics
• XML is for data
– Neutral, generic format
– Extensible (can create infinite number of
tags)
– Flexible
– Self documenting (human and machine
readable)
– Simple, easy to use
– Separates style from structure
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-72
To build data : XML Hierarchy
XML can be described in a
tree hierarchy
Document
Parent
Document
Unit
Sub-unit
Unit
Child
Sub-unit
Sibling
All elements must be nested
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-73
XML Technologies
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-74
XSL
XSL Transformations (XSLT)
Is a language for transforming XML documents
XSLT stylesheets
Stylesheets format XML documents
Use XSLT to interact with an XML document
Can format individual or groups of elements
within the XML document
A form of XSL that transforms the XML data using
processing rules in the XSLT stylesheet
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-75
XSL – Universal Presentation of
XML Data : How does it work?
• Binding XML to existing Web pages is fine, but
limited way to present XML data; CSS helps , but has its
own language; change style – need another CSS
• Universal and flexible way : create separate XSL file, which
defines how to present every element of XML data, merge
them together and create HTML page as a result ; both XML
and XSL files can be edited in code
XML
document
HTML Page
XSL
processor
XSL
document
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-76
inventory.xsd
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-77
XML ASP/ Database : Hot Stuff
• Typical Web Application now is a 3-tier architecture:
Web
Client
XML
XML
ASP
Server
XML
DataBase
Server
Recordset
• We want to create such an application with XML as
a data trasfer media :
– RS requested according to SQL from any relational DB to be
converted to XML
– XML at ASP server saved to a file and sent to a Client
– XML at Client modified/created , sent to ASP server,
validated/processed, data sent to DB for update
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-78
Quiz
•
Explain the differences between the execution of a Windows
application and a Web application.
•
Differentiate between the client and the server for a Web application :
what is running on a client and what is running at the server ?
• What is meant by the statement that Web pages are stateless?
• What are the differences between HTML controls and standard
ASP controls?
• How does event handling differ from that for Windows
applications?
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-79
Quiz ( cont.)
• Describe the purpose and functionality of AJAX. What is meant
by open standards?
• What is a Session object and how would it be used?
• What is the purpose of XML? of SOAP?
McGraw-Hill
© 2010 The McGraw-Hill Companies, Inc. All rights reserved.
9-80