July 10, 2003
Introduction to MS.NET
What is MS .NET
Old: .NET is the Microsoft platform for XML
New: .NET is the set of Microsoft
technologies for connecting your world of
information,people,systems and devices.
.NET is infused into the Microsoft platform
providing the ability to build,host,deploy and
consume XML Web service connected
Why MS .NET
.Interoperability between languages and
.Uniformity in schema or formats for
Data Exchange using XML,XSL
.Extend or use existing code that is valid
.Programming complexity of
environment is reduced
Services provided by MS .NET
A new run-time environment, the .NET Framework
A new programming model for constructing HTML
pages, named ASP.NET
A new way for Internet servers to expose functions
to any client, named XML Web services
Windows Forms, a new way of writing rich client
applications using the .NET framework
Support for db access within the .NET
Support for handling XML documents and streams
A standardized mechanism for signaling
Support for writing multithreaded code
Support for writing your own Windows Forms and
Web Forms controls
Component of MS .NET
.NET spans clients,servers and develop tools
such as MS visual studio.NET 2003
. A set of servers
including MS Windows server 2003,MS
such as Windows XP
What is .NET Framework
.NET framework is an integral Windows component for
building and running all kinds of software,including
web-based applications,smart client applications and
XML Web services.
. Support over 20 different programming languages.
. Manages much of the plumbing involved in developing
software,enabling developers to focus on the core
business logic code.
. Makes it easier than ever before to build,deploy,and
administer secure,robust and high-performing
Component of .NET Framework
. Common Language Runtime(CLR)
. A unified set of class libraries
.NET Framework Architecture
What is .NET anyway?
Microsoft .NET provides
infrastructure for solving
the common problems
of writing Internet
Common Language Runtime
Provide the common services for .NET framework
. Thread management
.Strong type naming
.Cross-language exception handling
. Dynamic binding reduce the amount of code
CLR: Execution Model
Source VB C# C++
Compiler Compiler Compiler Unmanaged
Managed Assembly Assembly Assembly
code IL Code IL Code IL Code
Common Language Runtime
Operating System Services
ASP.NET: building Web applications and
ADO.NET: connecting applications to
Windows Forms: an environment for
building smart client applications
Designed for disconnected access
Can model data logically!
The DataSet replaces the RecordSet
DataSet can contain multiple tables
Core Concepts and Architecture
The ADO.NET Object Model
Data Set Data Reader
Managed Data Provider
ADO.NET and Managed Providers
A collection of classes for accessing data sources:
Microsoft SQL Server™ 2000, SQL Server 7, and MSDE
Any OLE Database (OLE DB) providers
Including: Oracle, JET, and SQL OLE DB Providers
Establish connection between DataSets and data stores
Two managed providers:
ADO: via the System.Data.ADO namespace
SQL Server: via the System.Data.SQL namespace
System.Data.ADO is the ADO.NET managed provider
Connection with a Connection Object
A connection object represents a unique session with
a data source.
Connection string: database, OLE DB provider,
Use the Open/Close method to open/close a
Containing information about database, OLE DB
provider, password, if any, security, etc.
For Jet database:
info = False;Data Source=c:\ …\Nwind.mdb
dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
dim objConn as new ADOConnection(strConn)
The command object allows us to execute a SQL statement.
CommandType: SQL or stored procedure
CommandText: SQL statement
ExecuteReader: Creates a DataReader object that contains
the results of the query.
ExecuteNonQuery: Execute SQL’s INSERT, DELETE, UPDATE
It is read-only and forward-only cursor.
Read: Reads the current record and advances the
pointer to the next record.
Close: Closes the dataReader.
// Code for creating the ADOConnection “adoConn” not shown
String myQuery = “SELECT * FROM Customers”;
ADOCommand myCmd = new ADOCommand( myQuery,adoConn );
// Declare the ADODataReader...
// Instantiate the ADODataReader with Execute(...) ...
// Always call Read before accessing data.
// Always Close the reader and the connection when done
A DataSet object can hold several tables and
relationships between tables.
A DataSet is a set of disconnedted data. Data is
extracted from the database and stored in the
DataSet object. Updates to the DataSet must copy
back to the database to make the changes
DataSet and Related Objects
DataSet and Related Objects
DataSet: Can contain multiple tables and
DataTable object: Represents a table in the dataset.
DataAdapter: This the object used to pass data
between the database and the dataset. The Fill
method copies the data into the dataset, and the
Update method copies the updates back into the
DataView: This represents a specific view of the
DataTables held in the dataset.
System.Data—DataSet and XML
DataSet can read/write XML for its data and/or schema
Means: You can create or modify a DataSet using XML!
XML-related DataSet methods for reading:
ReadXml: Reads an XML schema and data into the
ReadXmlData: Reads XML data into the DataSet
ReadXmlSchema: Reads an XML schema into the
And for writing: WriteXml, WriteXmlData,
Methods of Reading and Writing XML
// Code for creating the DataSet mds and loading the
// DataSet from a data source not shown.
String oFile = “C:\\My_ADO.NET\\myXmlOutput.xsd”;
String iFile = “C:\\My_ADO.NET\\myXmlInput.xsd”;
// Write the DataSet’s XMLSchema to an XML Document
mds.WriteXmlSchema( oFile );
// Read/Upload XML Data into the DataSet
mds.ReadXmlData( iFile, true );
// Write the existing Data to an XML Document
mds.WriteXmlSchema( “C:\\My_ADO.NET\\myXmlData.txt );
// Or output the XML Data using the XmlData property!
Console.WriteLine( mds.XmlData );
ASP.NET is a new programming framework designed to make web
apps easier to:
Build, Deploy, Run
Radical advancement of today’s ASP
Broader programming language support
Visual Basic.NET, Jscript.NET, C#
Form-based programming model(similar to VB form)
Event driven programming
New application model
XML Web service
Mobile Web device support
Better reliability and recovery
Excellent Visual Studio support
Improved performance & scalability
ASP.NET is compiled, not interpreted
Rich output caching
Session state can now be shared across a web form
of ASP.NET servers
.NET State Server Process manages state
ASP.NET detects and recovers from problems
Access violations, memory leaks, dead
Web forms:building powerful forms-based
XML Web Services :providing the means to
access server functionality remotely.
The visual component(Web Form Pages)
consists of a file(.aspx extension)
(2) ASP.NET server controls
HTML server controls
Web server controls
The logic for the Web Form page(code)
separate file(.aspx.vb or .aspx.cs extension)
.NET Web Services
NET is built on Internet standard protocols
Uses Framework classes, such as
Enables communication through open
Service description expressed with WSDL
Basic wire format
Universal Description Discovery Integration
Define XML Web Services
To create an XML Web service, simply write a .NET object
as if it were being accessed directly by local clients, mark
it with an attribute that says this object should be
available to Web clients, and ASP.NET will do the rest.
ASP.NET automatically hooks up a prefabricated
infrastructure that accepts incoming requests through
HTTP and maps them to calls on the object
ASP.net for XML Web Services
• Creating a Web service
1. Create a file with an .asmx file name extension .
2.Within the file ,declare the XML web service using
3.Define the XML service methods that compose the
functionality of the XML Web service
• Creating a discovery file
Create a XML document with a .DISCO extension
(not compulsory to create)
Server-side view of XML Web services
1. HTTP requests arrive, with Windows 2000 server machine
method name and with .NET
parameters encoded in
URL or separate XML.
2. ASP.NET creates object
specified in .ASMX file.
5. ASP.NET converts results to
XML and returns to client 3. ASP.NET calls specified
via HTTP. method on object.
4. Object returns .NET object
results to ASP.NET.
Client-side view of XML Web services
0. At programming time, a developer generates proxy
object code from a description of an XML Web service.
1. At run time, client creates proxy object.
2. Client calls method on proxy.
3. Proxy converts call to HTTP via Internet
5. Client receives and XML and sends it to
return value server over the Internet.
4. Proxy receives results in
XML over HTTP and converts
to function return value.
Example: building a Web Service
<%@ WebService Language="VB" Class="TimeService"%>
Public Class TimeService : Inherits WebService
<WebMethod()> Public Function GetTime (ShowSeconds as Boolean) As String
If (ShowSeconds = TRUE) Then
Describing XML Web Services by WSDL File
To develop client applications that uses the XML Web services,
programmers need a description of what the service does and how to
use the service (e.g. methods exposed, parameters required by those
methods, protocols supported)
Problem: a universal approach not restricted to the MS world of
describing a service is needed!
Solution: The ASP.NET can generate such a description in the form of a
WSDL (Web Service Description Language) file.
To obtain the WSDL file from ASP.NET, request the .asmx file
with ?WSDL attached to the URL.
Alternatively, the developer can write the WSDL file first or obtain it
from a 3rd party to describe what the service should do, and use the
SDK utility program wsdl.exe to generate a template file.
The client application developer will probably not deal with raw WSDL
files but rather use them through interpretive tools to develop client
The WSDL file also shows the supported protocols and how to access
the service via these protocols from the client application.
Building XML Web Service Clients
ASP.NET funnels incoming requests to XML Web service
objects packaged in 3 different ways
SOAP (Simple Object Access Protocol)
SOAP is easier and more powerful than the other two methods.
1. A Web service client formats a SOAP request packet
2. The client sends the SOAP request to the XML Web service via an
HTTP POST operation.
3. The XML Web service parses the request, create the object, call
the method with the specified parameters, and return a SOAP
response to the Web service client.
Calling a Web Service via SOAP
A client-side SOAP proxy class makes client
applications much easier to write
The .NET Framework SDK provides wsdl.exe to
generate proxy class from the WSDL file for accessing
the methods in the specified language.
Visual Studio .NET uses the proxy class generator
Create a Windows Forms project
Add the XML Web service page as a Web Reference to the
project. This will run wsdl.exe internally and ask for a SOAP-
based proxy in the language of the project.
Visual Studio then displays the namespace of the proxy class
in Solution Explorer.
To access the XML Web service from the client, simply create
an object of the proxy class and call the desired method on it.
Web Service Discovery
This is the aspect of making the presence and capabilities of a
Web Service known to the world.
This is the UDDI (Universal Discovery, Description, and
Integration) business registry service.
Initiated by Ariba, IBM, and Microsoft. Supported by more than
Provides a standard place to register Web Services. Check out
UDDI is a specification built on SOAP/XML and defines a
document format and protocol for searching and retrieving
discovery documents - which in turn link to DISCO documents.
DISCO (Discovery of Web Services) is a Microsoft protocol for
retrieving the contracts for Web Services (WDSL documents).
Calling a Web Service via HTTP Get
By requesting a Web Service URL from the IE Address
field, ASP.NET will respond with a neatly-formatted page
that describes the Web Service and it’s methods. This
page even provides a simple means to run the methods.
This is not UDDI or DISCO. Just a nicely-formatted page
built from the metadata.
You can get the WSDL by appending “?wsdl” to the URL.
To call a method, append the method name and
parameters to the URL like this:
Calling the service in this manner will result in a simple
XML response containing the return value.
Calling a Web Service via HTTP Post
The WSDL describes the requirements for doing this.
The Web Service expects that the incoming
parameter values be contained in FORM fields with
specific names. Therefore, the FORM has to contain
INPUT elements named according to the WSDL. The
ACTION attribute names the method:
<FORM Method=“Post” Action=“TimeServiceVB.asmx/GetTime”>
The response is an XML string.
Visual Studio .NET
Increased programming productivity
Easier to write code: drag and drop Web App and
Fully supports the .NET Framework
Powerful design tools
Windows Forms, Web Forms
XML and component designers
Consistent set of tools across languages
Integrated Development Environment
Many language enhancements
Inheritance,Overloading, Free Threading
Integration with .NET Framework with managed extensions
New development language
Based on C/C++ with Garbage Collection/Memory Management
JUMP (Java User Migration Path) to .NET (1/25/01)
Visual J++ has been removed from the Visual Studio suite.
Single IDE for all Languages
Event Viewer, Message Queues, Services
SQL Databases, Data Connection, Etc.
Integrated IE Browser
Common Forms Editor
VB.NET, C++, and C#