32
tom perkins 1 XML Web Services - .NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

Embed Size (px)

Citation preview

Page 1: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 1

XML Web Services - .NET FRAMEWORK – Part 1

CHAPTER 1.1 – 1.3

Page 2: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 2

.NET

provides

Development tools

Runtime environments

Server infrastructure

Intelligent software

Enabling you

to build

Applications for various platforms and

devices

Page 3: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 3

.NET

Uses standards to integrate applications and devices

Hypertext Transfer Protocol (HTTP) XML SOAP

Page 4: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 4

.NET

Application 1 Application 2

Allows applications to exchange data using XML Web Services

XML Web Services

Page 5: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 5

.NET

Process A

Process 1

Process 2

Provides remoting infrastructure

Allows applications running in different processes (same or different computers) to exchange data

Uses HTTP or binary protocols

Page 6: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 6

.NET Tools and

Operational Systems

Smart Client Software XML Web Services

.Net Server Infrastructure Visual Studio .NET and the .NET Framework

Access data from any location by PC, mobile, or client using Web Services

Secure and scalable platform for distributing Web apps

Includes:Windows 2000 servers

.NET Servers

.NET Enterprise Servers

Core to app integration

For Internet and Intranet apps; exchange data using HTTP, XML and SOAP

Build, host, and consume web apps

Page 7: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 7

Desktop computer

Mobile device

XML Web Services

Servers:

Web Services

•Allow client app to exchange data with another client or server

•Server apps to exchange data with one another

•Apps on any device with apps on any other device

Page 8: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 8

European Computer Manufacturers Association

standard defines

CLS-Rules for language interoperability - Syntax

CLI - Semantics

VisualBasic .NET

VisualC# .NET VisualJ# .NET Visual C++ .NET

CLS Compliant

Framework runtime engine executes MSIL

all produce

Intermediate Language (MSIL) code

Page 9: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 9

CLI Specifies, .NET Framework provides:• Common Language Runtime (CLR)

• provides execution environment• CLR loads and executes your MSIL code

• Common Type System (CTS)• a string in VB is a string in C#• provides data, value, and object types • no language superiority in .NET

• Type safety• Operations performed on one type are performed on that type only• Each value has a type, each reference has a type

• Managed Code• .NET loads and executes code, allocates memory, provides automatic garbage collection

• Side-by-Side execution• Assemblies are deployment units in .NET• Assemblies contain IL code and metadata (name, version, version of dependent assemblies)• Different versions of app can run side by side

Page 10: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 10

VisualBasic .NET

VisualC# .NET VisualJ# .NET Visual C++ .NET

Web Forms XML Web Services

ASP.NET

.NET Framework Class Library – all common .NET Types

Windows Forms

Win 32

Common Language Runtime

Loads IL code, compiles into native code, enforces security and type safety, provides thread support

(managed code)

Main components

of .NET Framework

Page 11: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 11

Understanding the Common Language

Runtime (CLR)Lesson 2

Page 12: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 12

What we’ll look at …

CLR

Architecture

CLR Components

Functions of CLR

components

Page 13: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 13

CLR Components

Class loader

Loads classes into the runtime

MSIL/native compiler

Code manager

Garbage collection

Security engine Type

checkerThread Support

Exception mgr

Debug engine

COM marshaller

Base class support

Converts MSIL code to native

codeManages

code during

executionAutomatic memory

management

Enforces security

restrictionsStrict type enforceme

nt

Multi-threading support for apps

Execption handing

mechanism

Debug diff types of

apps

Exchange data with COM apps

Provide types for apps at runtime

Page 14: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 14

For a program to run in the CLR:

Source code

CLS-compliant compiler

Metadata Intermediate code (MSIL)

•Instructions are CPU- independent

•Must be compiled into CPU-dependent instructions

•Describes the code

•Identifies types used in code

•Contains references to other types used

Located in portable executable file

Page 15: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 15

Just-in-Time (JIT) Compilation

Portable execution file

•Metadata

•MSIL

Class loader

Portable execution file

•Metadata

•MSIL

CLR Memory

Loaded into

memoryJIT Compiler (different for different CPU architectures) Compiled only 1st time usedNative code

Native code used on 2nd+ use

Page 16: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 16

Program initiation

Portable execution file

•Metadata

•MSIL

CLR MemoryCode

managerCalls entry point method•Main•WinMain•dllMain

• places objects into memory• controls execution

Native code

Garbage collector•Checks objects on heap•Identifies objects no longer required•Removes them

Page 17: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 17

During execution

•Objects

•Values

•References

CLR Memory

Native code

Type Checker

Makes sure everything has a valid type

Makes sure only valid operations are performed (int value assigned to int variable)

Err raised if string assigned to int

Security Engine

•Enforces security restrictions

•Controls access to resources

•Hard disk

•Network connections

Page 18: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 18

Managed multithreading support

Single process

Application domain Application domain Application domain

Can be divided into subprocesses

Each domain can contain one or more threads

Runtime monitors all threads in process

Page 19: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 19

Interoperating with unmanaged code

CLR – Managed Code

Managed CodeCOM Marshaller

Data represented differently in diff environments

COM Marshaller converts data formats when data is exchanged

Page 20: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 20

Other Components in CLR

Structured Error Handling Mechanism

Base Class Library Support

Common Debug Engine

Handles debugging in any CLS Language

Debug on both local and remote computers

Page 21: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 21

CLR – Managed Execution Process

eLearning – Chapter 1 Lesson 3

Page 22: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 22

Managed Execution Process

• Runs the application from within the CLR– Loads and executes the application

• One major advantage – Automatic Memory Management – garbage collection

• Other services performed:– JIT compilations– Ensuring type safety– Enforcing security– Handling exceptions

Page 23: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 23

Managed Execution Processinvolves

Managed Code

Managed Data

• Self-describing code• Provides info to CLR• Gets run-time services from CLR• Info stored in metadata in portable executable files

• describes code• describes types used by code

•Allocated and released by garbage collector

Managed code can access both managed and unmanaged data

Page 24: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 24

With Garbage Collection, you don’t need to worry about:

• Allocating memory• Not releasing memory that is no longer

required• Trying to access released memory

• Tasks of Automatic Memory Management– Allocating memory– Releasing memory– Implementing Finalizers

Page 25: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 25

Memory Allocation

• Process is initiated• Contiguous address

space is reserved (managed heap)

• Pointer established (where next object will be located)

• new creates new object

• Memory allocated• ObjPtr moved

Managed Heap

ObjPtr

ObjPtr

new object

•Much faster than unmanaged memory allocation• new operator may throw Out of Memory exception

Page 26: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 26

Releasing Memory• Application – set of roots

– Point to object on heap or are null– Global and static object pointers– Local variables– Reference object parameters on thead stack

• JIT compiler and runtime maintain list of roots• Garbage collection creates a reachability graph• Initially, all heap is considered garbage• GC, using root list, identifies reachable objects• GC collection process, frees memory on stack• Compression through memory copy• GC updates the root pointers on the list

Page 27: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 27

More Garbage (Collection, that is)

• Objects on heap divided – Generations 0,1,2

• Generation 0 – recently created• Gen 0 searched, collected,

compressed• Surviving objects promoted to higher

generation• Gen 1,2 searched for unreachables

only when needed

Page 28: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 28

GC

• Can’t clean system resources (file handles, connection, etc) used by managed code

• You must release memory in Dispose method

• You must explicitly call Dispose method after you finish working with the object

Page 29: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 29

Finalize Method

• Release system resources in Finalize method code

• GC calls Finalize before releasing memory for that unreferenced object

Page 30: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 30

Finalization (Code cleanup)

Finalizers – methods called just before object is garbage-collected.

2 Special methods – Dispose and Finalize

Dispose method should release its resources plus resources owned by parent. Do so by calling Dispose() on the parent.

Parent Object

Dispose()

Your Object

Dispose()

Page 31: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 31

Dispose Method – 2 ways to execute

Dispose()………

YourClass

………

1) Call Dispose directly from your code……

-- or –

Finalize()

2) call Dispose from your Finalize method.

(Can clean both managed and unmanaged resources)

(Dispose can clean only unmanaged resources - GC may have already got ‘em)

Executed at GC time

Dispose() should call GC.SupressFinalize() method – keeps GC from cleaning up twice

Page 32: tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3

tom perkins 32

Looking Ahead

Portable executable file

MSIL

Assembly Manifest

•Contains info about assembly and resources required (type data)

•Runtime uses assembly manifest to load assemblies into runtime – required

All about Assemblies