Tonight’s Agenda
• Administrative– Order form validation homework– bEssentials– Final exam
• Introduction to ASP.NET Web Server Controls• XML• Web Services
Administrative – bEssentials
• Peer evaluations: based on contribution effort towards the team, showing up for meetings, meeting commitments for deliverables, etc.
• 5 percentage points out of the 30 percentage points for the project, proportional to the overall group score
• Allocate points from the pot to your team members:
Team Size Point Pot
4 15
5 20
6 25
• Don’t exceed the # of points you have to allocate! If you do, they come out of your points!
• Don’t give yourself any points!• Due on the day of the final – if you forget, you get
ZERO for peer evaluation
Administrative – bEssentials
• Deliverables on the Final Exam day:– Peer evaluation scores– All files uploaded to Cypress– On a single sheet of paper:
• Names of your team members• URL of your company’s home page• URL of any web pages that your team is especially
proud of and would like to bring to my attention• Anything else about your web site that you’d like to
point out for grade evaluation• Be prepared to do a 5 minute demo of your web site in
front of the class before we begin the final exam
Introduction to ASP.NET Web Server Controls
• Basic controls (text box, radio button, check box) are similar to HTML controls
• Radio Button List & Check Box List ASP.NET controls do the grouping for you– Retrieve list contents from a data source or list
collection– Dropdown List ASP.NET control uses same
implementation model• AutoPostBack attribute for immediate or deferred form
processing• Additional information:
– Chapter 4 of the text– http://www.asp.net/Tutorials/quickstart.aspx,
ASP.NET Web Forms topic
ASP.NET Validation Controls
• Does form validation in response to a button click event– Required field (asp:RequiredFieldValidator)– Range checking of input data
(asp:RangeValidator)– Verify the input data against a format such
as email address, Social Security Number or minimum character length (asp:RegularExpressionValidator)
– Compare two data from two form controls (asp.CompareValidator)
Example: form-demo.aspx
• Web Matrix Technique highlights– Page properties: Events (lightening bolt):
Load (double-click) to create Page_Load subroutine template
– Create ListItems for a list control by clicking on (…) icon in collections
• Programming techniques– RadioButtonList1.SelectedIndex=-1 to
deselect all items in the list• See what happens when you:
– Set AutoPostBack = "False"– Set CausesValidation = "True"
XML - Introduction
• Core technology for one of the hottest areas in IT today
• An essential, "must know" topic if you want to stay current in web programming
• An excellent format for packaging and communicating data between humans, machines or both– Firewalls may block binary data, XML is text
only so it doesn’t have any problems getting through
XML – Overview
• XML = eXtensible Markup Language• But it’s really not a language• It’s a standard format for writing your own
language in a way that other people (and applications) can easily learn
• Resembles HTML, similar to XHTML in terms of grammar rules (nesting, end tags, attribute values in quotes, comments, etc.)– Tag names are case sensitive!
XML’s Hidden Role in .NET
• XML’s most useful place isn’t in a web application you might create, rather it’s in the infrastructure supporting your web application
• Places where .NET makes use of XML:– ADO.NET Data Access– Configuration files like web.config– Web Services– Anywhere that .NET needs to store
miscellaneous data such as the list of files to display in the AdRotator control
XML Basic
• Compare these two product catalog data files
Traditional text file format:1Chair49.331132Car43399.55973Fruit Basket49.9983
XML file format:<?xml version = "1.0"?><ProductList> <Product> <id>1</id> <name>Chair</name> <price>49.33</price> <StockQty>113</StockQty> </Product> <Product> <id>2</id> <name>Car</name> <price>43399.55</price> <StockQty>97</StockQty> </Product> <Product> <id>3</id> <name>Fruit Basket</name> <price>49.99</price> <StockQty>83</StockQty> </Product></ProductList>
XML
• XML isn’t a replacement for a real database– XML doesn’t have all of the mechanisms
that a database package has (to enforce table relations or manage concurrency issues, for example)
• In addition to the XML document itself, there are two other components:1.Document Type Definition (DTD) or XML
Schema (XSD)2.eXtensible Style Sheets (XSL) – optional for
displaying the XML document
DTD Example
book-instance.xml<?xml version="1.0"?><BOOK InStock="true"> <TITLE>The Marble Faun</TITLE> <AUTHOR>Nathaniel Hawthorne</AUTHOR> <BINDING>trade paperback</BINDING> <PAGES>473</PAGES> <PRICE>10.95</PRICE></BOOK>
book-dtd.dtd<!ELEMENT INVENTORY (BOOK) *><!ELEMENT BOOK (TITLE, AUTHOR, BINDING, PAGES, PRICE) ><!ATTLIST BOOK InStock (true|false) #REQUIRED ><!ELEMENT TITLE (#PCDATA) ><!ELEMENT AUTHOR (#PCDATA) ><!ELEMENT BINDING (#PCDATA) ><!ELEMENT PAGES (#PCDATA) ><!ELEMENT PRICE (#PCDATA) >
XML Schema Example
book-schema.xsd<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="BOOK"> <xsd:complexType> <xsd:sequence> <xsd:element name="TITLE" type="xsd:string"/> <xsd:element name="AUTHOR" type="xsd:string"/> <xsd:element name="BINDING" type="xsd:string"/> <xsd:element name="PAGES" type="xsd:positiveInteger"/> <xsd:element name="PRICE" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="InStock" type="xsd:boolean" use="required"/> </xsd:complexType> </xsd:element></xsd:schema>
XML Facilities in .NET
• Handle XML as a special type of text file– XmlTextWriter, XmlTextReader– Text stream I/O (you need to construct tags
by specifying element names)– Good for storing simple blocks of data
• You need to keep track of the structure and the order of the element tags (<name> then <price> then <StockQty>, for example)
– Maintains connection to the actual data
XML Facilities in .NET: XmlTextWriter
Dim fs As New FileStream ("c:\myFile.xml", FileMode.Create)Dim w As New XmlTextWriter(fs, Nothing)w.WriteStartDocument()w.WriteStartElement("SuperProProductList")0‘ Write the first productw.WriteStartElement("Product")w.WriteAttributeString("ID", "", "1")w.WriteAttributeString("Name", "", "Chair")
w.WriteStartElement("Price")w.WriteString("49.33")w.WriteEndElement()
w.WriteEndElement()
‘ Close the root elementw.WriteEndElement()w.WriteEndDocument()w.Close()
XML Facilities: XmlTextWriter (cont’d)
• Produces this XML file:
<?xml version="1.0">
<SuperProProductList>
<Product ID="1" Name="Chair">
<Price>49.33</Price>
</Product>
</SuperProProductList>
XML Facilities in .NET
• Handle XML as a collection of in-memory objects– XmlDocument, XmlNode– Makes the entire XML document structure
available as an in-memory object• You set values to node properties, order of the
element tags is maintained for you• Tag pairs (<name> </name>) handled for you
– Offers ability to search for content by element ID or element tag name
– A copy of the original data– Similar in concept to ADO.NET DataSet
XML Facilities in .NET
• Handle XML as a special interface to relational data– XmlDataDocument– Lets you read an XML document and then
bind it to ADO.NET data controls such as DataGrid
XML Facilities in .NET
• Process an XML document through XSL (to create an HTML document, for example)– XmlTransform to generate the output
stream– Xml takes XmlTransform output to generate
an HTML page
XML Demo Programs
• All of these programs use the rental.mdb from B188
rental-XMLDataSet.aspx Creates an XML doc from a table
rental-XMLDataSetJoin.aspx Creates an XML doc from joining the three tables
rental-XMLDatagrid.aspx Displays an XML doc using a DataGrid
rental-XMLDataSet3Table.aspx Dumps all 3 tables to XML
rental-XMLDatagrid3Table.aspx Displays output from XMLDataSet3Table.aspx
Web Services - Introduction
• Why? The architecture for Internet applications is very similar to the client/server architecture of about five years ago: monolithic, a full-featured application containing a variety of services behind a single proprietary user interface
The Era of Monolithic Applications
• Single web application offering a comprehensive set of services such as a financial services site (with access to individual savings, credit card, insurance information and services)
Limitations of Monolithic Applications
• Take a lot of time and resources to create• Often tied to specific platforms or technologies, can’t be
easily extended or enhanced• Difficult to get multiple applications to work together
beyond just a hyperlink • Units of application logic can’t easily be reused between
applications (this is the next level above just sharing source code or object classes)
• You have to go through the complete, monolithic application even if all you want is a simple piece of information (such as your savings balance or the current loan rate for a specific program)
Components and the COM Revolution
• On the standalone desktop application level, Microsoft addressed these problems through their COM (component object model) technology which produced ActiveX controls– A lot of the individual functional services
inside of Word and Excel are available as ActiveX controls, for example
• Web Services offers the same re-usable and more easily accessible functionality over a networked environment
Web Services and the Programmable Web
• Web Services are individual units of programming logic that exist on a web server
• Built on open standards, not a platform-specific binary standard
• Think of it as being able to call classes/subroutines/functions over a network
Web Services Standards
Standard Description
WSDL Web Service Description Language: describes the interface (methods, properties) that the service offers to client applications
SOAP Simple Object Access Protocol: the preferred means for encoding information between the Web Service & client
HTTP Base transport protocol
DISCO A standard for describing what Web Services are available on a site
UDDI Universal Description, Discovery and Integration: a registry for listing Web Services available throughout the Internet.
WSDL
• XML-based• Contains only the information for
communication between a Web Service and client, nothing on the inner workings of the service– Designed for reading by applications
• To see the WSDL for an ASP.NET Web Service, add ?WSDL to the query string:http://localhost/WebService/myWebService.asmx?WSDL
SOAP
• One of the three supported standards for the transmission of Web Service information (the other two being HTTP GET & HTTP PUT)
• HTTP GET/PUT sends information as simple name/value pairs, SOAP uses a well-formatted XML document
DISCO
• Web Services are available at a specific URL address. How do you let the world know about this address? What if you need to change the address?
• DISCO is a machine-readable "HTML page with links to Web Services"
• As long as your application knows how to find the site’s .disco file, it can then find all of the Web Services available at that site
UDDI
• Proposed by Microsoft, very new and not yet widely adopted
• Conceptually equivalent to a Yahoo! for web services
• Sits at the level above DISCO files. It’s a means for businesses to advertise all the Web Services they have
• The UDDI registry itself is a Web Service• Details at http://uddi.microsoft.com
Communicating with a Web Service
Web Application
Service Class
Methods
Standalone Web Application
Web Application
ProxyClass
Methods
Web Service Client
Web Service Class
Web Service
Internet
Creating a Web Service
• Code a .asmx file<WebService (Description:="Bus118W Web Service demo",
_ Namespace:="http://cob.sjsu.edu")> _ Public Class GetTransactions Inherits WebService
• Put it through the WSDL compiler to generate a Visual Basic source file:wsdl.exe /language:vb
http://localhost/rental-XMLWebSvc.asmx?WSDL
• Compile VB source file to generate proxy DLLvbc.exe /t:library /out:GetTransactions.dll
/r:system.dll /r:system.web.dll /r:system.web.services.dll /r:system.xml.dll /r:system.data.dll GetTransactions.vb
XML & Web Services Demo Programs
• All of these programs use the rental.mdb from B188
• Commercial web services– WeatherByZipClient.aspx
• Calls a web service that returns current weather conditions for a given ZIP code
– GoogleAPIClient.aspx• Calls a web service operated by Google
rental-XMLWebSvc.asmx Web Service that extracts some rental transactions
rental-XMLWebSvcClient.aspx Client to call the Web Service and display results in a DataGrid