Tài liệu Introduction to XML Services - Pdf 85

1
Introduction to
XML Services
CERTIFICATION OBJECTIVES
1.01 Overview of .NET
1.02 Visual Basic .NET
1.03 Implementation in Visual Basic .NET
1.04 .NET Assemblies
1.05 .NET Component Models

Two-Minute Drill
Q&A
Self Test
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /
Chapter 1
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:44 AM
Color profile: Generic CMYK printer profile
Composite Default screen
I
n this the first chapter of the MCAD/MCSD XML Web Services and Server Components
Development with Visual Basic .NET Study Guide (Exam 70-310), I will present the background of
the .NET Framework and the different languages and products that make up the Framework.
You will specifically learn about the .NET Framework and how the Common
Language Runtime (CLR) and the Common Type System (CTS) work together.
The computer language the 70-310 exam uses is Visual Basic .NET, and you will
also get a refresher in how to use it.
When Microsoft released the .NET platform, the world of computing changed
for all computer professionals, even though the term .NET means different things
to different professionals. Network administrators think of .NET as the new servers
including the new .NET Server Operating System, while for us developers it means


Is platform independent

Provides a common runtime environment

Uses common data types
To implement a system that meets these goals, Microsoft’s engineers designed a
new type of computer platform that encapsulates (hides) the hardware and the
operating system from the developer. These parts make up the .NET Framework:

Common Language Runtime (CLR)

Common Language Specification (CLS)

Microsoft Intermediate Language (MSIL)

Base Class Library (BCL)
Figure 1-1 depicts the architecture of the .NET Framework.
The most important feature of the .NET Framework, and from a developer’s point
of view the most exciting one, is the Common Language Runtime (CLR)—the CLR is
the software platform that our applications are written to run on. Another way to look
at the CLR is to say that the CLR implements the Common Type System (CTS). The
following sections will delve deeper into these parts of the .NET Framework.
Common Language Runtime
The Common Language Runtime is the platform under which our code will run,
and the language of the CLR is Microsoft Intermediate Language, which is the
language our application will be compiled to. The reason you compile to an
intermediate language is to avoid the hardware and operating system dependencies
that traditional environments give us. The CLR in turn will compile the MSIL into
the native language of the hardware platform. Figure 1-2 shows the major parts of

P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:45 AM
Color profile: Generic CMYK printer profile
Composite Default screen
Overview of .NET
5
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /
Chapter 1
FIGURE 1-2
The Common Language Runtime
Visual Basic .NET Data Type CLR Data Type Description
Sbyte System.Sbyte 8-bit signed integer
Short System.Int16 16-bit signed integer
Integer System.Int32 32-bit signed integer
Long System.Int64 64-bit signed integer
Byte System.Byte 8-bit unsigned integer
UInt16 System.UInt16 16-bit unsigned integer
UInt32 System.UInt32 32-bit unsigned integer
UInt64 System.UInt64 64-bit unsigned integer
Single System.Single Single-precision floating point value
Double System.Double Double-precision floating point value
Char System.Char Unicode character
Decimal System.Decimal Exact decimal with 28 significant digits
Boolean System.Boolean Boolean value
TABLE 1-1
The Visual Basic .NET Data Types Related to the CTS
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:45 AM
Color profile: Generic CMYK printer profile
Composite Default screen

The part of the .NET Framework that gives us the ability to build complex
applications right out of the gate is the Base Class Library, which contains the classes
used to build Windows Forms, among other things.
Base Class Library
The .NET Framework is totally object oriented, as is the Base Class Library. This
library of classes that is used to build the complex applications you have become
familiar with is built upon a hierarchy that uses a “dotted” notation to keep the
different parts of the application separated. For example, to refer to the Int32 class
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:45 AM
Color profile: Generic CMYK printer profile
Composite Default screen
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /
Chapter 1
in the System namespace, you would write System.Int32. The namespace can be
thought of as an alias for a longer name.
The Base Class Library (BCL) is what gives the .NET Framework its power and
its look and feel. When you need to build a Windows Form, you start by inheriting
from the System.Windows.Forms.Form class. This is the class that provides the basic
behavior we expect a Form to have. This ability to draw on a library of common
classes is very powerful.
The BCL is very big—I could fill a book just on the classes in the BCL and
all the members (properties, methods, and events) of those classes. Fortunately,
you do not have to memorize all those classes; generally the exam will not test
you on your ability to remember minutiae of the common classes. I will point
out the few exceptions to this rule as you reach them in the following chapters.
The documentation for the BCL is in the Microsoft Developer Network Library
(MSDN) that was delivered with Visual Studio .NET, or you can view the
library online at .
The BCL provides the base classes that are used to build most of the applications

Information Services (IIS) version 3, which was released early in the product life
cycle of Windows NT Server 4. The current version of IIS is version 5, which was
released with Windows 2000—ASP.NET is the version of ASP that works together
with IIS 5 and the .NET Framework.
Any Web-based application operates like this: The client sends a request to the
web server using the Hypertext Transfer Protocol (HTTP). The request is for a file
with the ASP.NET file extension—.aspx. When IIS receives the request for the
file with the .aspx extension, IIS redirects the request to the ASP.DLL component
that will execute the .aspx file and return Hypertext Markup Language (HTML)
code to the client. Figure 1-3 shows this process.
The processing that takes place in the ASP.NET program uses the object model of
ASP.NET to gain access to the request from the client (Request Object), process the
request, and build the package that will be returned to the client (Response Object).
The ASP.NET objects also help with the data storage between calls from the client
(Session Object) and the web application as a whole (Application Object). The
building of a Web application is a topic for a different exam.
The preceding discussion has been a whirlwind tour of the .NET Framework and
its technologies. The coverage is by no stretch of the imagination exhaustive and
should be used only as a reminder of what the .NET Framework is all about.
The next section is a review of the Visual Basic .NET language.
8
Chapter 1: Introduction to XML Services
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind /
222653-6 / Chapter 1
FIGURE 1-3
How an ASP.NET request is handled
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:46 AM
Color profile: Generic CMYK printer profile
Composite Default screen

Visual Basic into a new realm where you can build more than just Windows forms.
In previous versions of the Visual Basic language, we had the capability to build
object-oriented components such as COM components by using the class file. The
model, unfortunately, did not include the OO concept of inheritance, where you
can create increasingly more specialized classes built on more general classes.
In this section, you will have a look at some of the new capabilities as a quick
introduction to Visual Basic .NET. The basics of writing code in the Visual Basic
Visual Basic .NET
9
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /
Chapter 1
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:46 AM
Color profile: Generic CMYK printer profile
Composite Default screen
10
Chapter 1: Introduction to XML Services
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind /
222653-6 / Chapter 1
.NET language are not within the scope of this book. For you to learn the
language, I recommend Visual Basic .NET: A Beginner’s Guide by Jeffrey Kent,
(Osborne/McGraw-Hill, 2002).
Object-Oriented Visual Basic .NET
Because the .NET Framework and the .NET languages are fully object-oriented
(OO) implementations, it is advantageous to use the OO model when building
applications using Visual Basic .NET. This section is a refresher for the OO
terminology and what makes up the OO world.
OO is based on the real world, where you see and use objects; for example, you
can see a car and you can use a car; you can agree that a car is an object. The car
itself is constructed of multiple objects (wheels, seats, engine, transmission, and so

CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /
Chapter 1
contains other objects; For example, think of the car: the car as an object is made up
of many other objects, wheels, engine, transmission, and so on. Containment is
described using the wording has a; for example, a car has an engine.
Polymorphism Another very powerful practice is the ability to write code at design
time without knowing what the object will be at run time. What makes this technique
work is that you can build models of objects that are related as siblings to each other.
Polymorphism uses late binding to be able to determine the object at run time.
Overloading Overloading is a technique that allows you to create methods with
the same name that can take different parameter types. It is the data type of the
parameter (or parameters) that determines the signature of the method; for example,
GetHelp(topic as String) and GetHelp(topicID as Integer)
are two overloaded methods with different signatures.
Overriding Overriding is a technique in which one object (the child) inherits
from another object (the base). The base object has a method defined that performs
some operation, and the child wants to further enhance the method to perform the
task specifically for itself. By defining the same method (the signature must be the
same) in the child object as in the base, you override the base method.
Continuing our earlier vehicle example, you can say that the vehicle object (the
parent) defines a method you call Start(speed as Integer) that sends
messages to the engine to start and accelerate to the speed requested. In the car
object (the child), you need to handle the transmission and the brakes in a special
manner, so you define a method that has the same signature (Start(speed as
Integer)) to perform those extra steps.
In the next section, you will look at how to implement some of these techniques
using Visual Basic .NET.
CERTIFICATION OBJECTIVE 1.03
Implementation in Visual Basic .NET
Before I delve into the implementation of some of the new features in Visual Basic

End Set
End Property
Public Property Fuel() As Decimal
Get
Return m_Fuel
End Get
Set
m_Fuel = Value
End Set
End Property
' By marking the following methods as Overridable we make it
' possible to override them in any child class
Public Overridable Sub Starter(FinalSpeed As Integer)
' no implementation, we do not know how to start the generic vehicle
End Sub
Public Overridable Sub Stopper()
' no implementation, we do not know how to stop the generic vehicle
End Sub
End Class
In designing this class, you made some assumptions: the vehicle can have a speed
and hold some fuel. Otherwise, the class does not do too much. To reuse the vehicle
class when you create the car class, you include a second line in the class declaration
that specifies the inheritance, as can be seen in the following code segment:
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:46 AM
Color profile: Generic CMYK printer profile
Composite Default screen
Implementation in Visual Basic .NET
13
CertPrs8 / MCAD/MCSD XML Web Services and Server Components Development with Visual Basic .NET / Lind / 222653-6 /

End Sub
End Class
The sports car has only one extra bit of functionality—it can accelerate fast. This
was an example of how classes can inherit from other classes that have inherited from
yet other classes. A class diagram seen in Figure 1-4 illustrates the preceding example.
Once you have related your objects with inheritance, you can start looking at
ways to make the same method call handle many different situations by using
overloading. The next section details method overloading.
Overloading
There are times when you really want to have the same method name accept many
different parameter data types, and this is where overloading comes in. Overloading
is the technique that allows you to have multiple methods with the same name but
P:\010Comp\CertPrs8\653-6\ch01.vp
Wednesday, October 30, 2002 9:45:46 AM
Color profile: Generic CMYK printer profile
Composite Default screen


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status