Net Remoting pdf

74 2.5K 3
Net Remoting pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1 HO CHI MINH UNIVERSITY OF INDUSTRY .NET Remoting 2 HO CHI MINH UNIVERSITY OF INDUSTRY Net Remoting Definition: • Application which is located in another application domain or process can communicate with another by using .Net Remoting. • Net Remoting allows processes to share the objects. It can call the method and can access the properties of an objects that are: 3 HO CHI MINH UNIVERSITY OF INDUSTRY  Hosted in different application domain with in the same process or  Different process executing on same computer or  Different computers connected by LAN or  Different computer distributed over world wide 4 HO CHI MINH UNIVERSITY OF INDUSTRY Modern applications are no longer stand-alone applications. .NET Remoting: - Provides a solution for communication between application domains 5 HO CHI MINH UNIVERSITY OF INDUSTRY You known Application Domain ?: Application domain is the collection of classes, which isolate these from other applications. The application in one application domain could not access the application in other application domain (without using Remoting) 6 HO CHI MINH UNIVERSITY OF INDUSTRY 2 Object type • It can be accessed outside its application domain. Remotable Object Non Remotable Object  CLR objects cannot, by default, be used outside their AppDomain - No way to copy them - No way to reference them  Exception occurs when you try to pass an object reference to a different domain  SO: It can not be accessed outside its own application domain. 7 HO CHI MINH UNIVERSITY OF INDUSTRY Remotable Object:  Can request that instances of a class be accessible outside original AppDomain – Client get a copy of the object – Client get a reference (proxy) to the original object  When an object is Remotable? The object should inherit the class System.MarshalByRefObject  Two Types of Remotable Objects are there – Marshal by Value – Marshal by Reference *More detail later 8 HO CHI MINH UNIVERSITY OF INDUSTRY Object Serialization: Conversion of an object (instance) into a data stream of bytes, Serialization is a method of persisting objects for storage in a database, to various media, or during marshaling—the process of moving an object to a new application domain, context, process, or system. Serialization is performed by the Common Language Runtime (CLR). 9 HO CHI MINH UNIVERSITY OF INDUSTRY MarshalByRef objects:  When the object's class derives, directly or indirectly, from MarshalByRefObject, the runtime creates a proxy to the object [Serializable] class Foo : System.MarshalByRefObject { . . . }  Clients in foreign AppDomains receive proxy  How does a client specify what proxy? 10 HO CHI MINH UNIVERSITY OF INDUSTRY Serializable objects:  When runtime can make a copy of the object, an object can marshal-by-value to other AppDomains – Add SerializableAttribute – Or implement the ISerializable interface [Serializable] Class Far { . . . } [...]... INDUSTRY ASP .NET Web services (WS) vs NET Remoting (NR) See next slide… 12 HO CHI MINH UNIVERSITY OF INDUSTRY 1 WS: only be accessed over HTTP; NR various protocols like TCP, HTTP etc 2 WS stateless environment, NR state management 3 WS more reliable than NET Remoting 4 WS are easy to create and use, NR are complex to be created 5 WS across platforms, NR requires client to be built using NET 6 WS support... in the XSD type system while NET remoting provides support for rich type system using binary communication 13 HO CHI MINH UNIVERSITY OF INDUSTRY Net Remoting components A remotable object A host application – listen to requests for the hosted remotable object A client application – requests for the remotable object 14 HO CHI MINH UNIVERSITY OF INDUSTRY How Does NET Remoting Works?  In the client... client 15 HO CHI MINH UNIVERSITY OF INDUSTRY Proxy  To avoid conjunction in networking It contains reference to all methods and properties of object There are two type of proxy – Transparent proxy (There is no physical existence, Created by IISserver) – Real Proxy (Physical Existence) 16 HO CHI MINH UNIVERSITY OF INDUSTRY  Remoting makes an object in server available to code in client => marshalling... objects 20 HO CHI MINH UNIVERSITY OF INDUSTRY Server-activated objects: Obj 1 Singleton Singlecall Obj A Obj 2 Obj n Obj 3 Obj 4 Share Share Share 21 HO CHI MINH UNIVERSITY OF INDUSTRY Terms using in Net Remoting  Channel  Formatters 22 HO CHI MINH UNIVERSITY OF INDUSTRY  Channel:  The medium through the which the messages would be transferred  The remote objects are to communicate with one another... protocol Using SOAP method allows the client to call method on the remote object that might not be using Net framework TCPChannel – use binaryFormatter to serialize message into binary stream 24  Channel: HO CHI MINH UNIVERSITY OF INDUSTRY We have to register at least one channel to use with the remoting infrastructure before being able to call the Remotable type from the client application We can... you configuring your channel’s port and the remoting system will choose an available port for you 25 HO CHI MINH UNIVERSITY OF INDUSTRY  Formatters Change the data in an appropriate format that it can traverse through channels There are two types of formatters – Binary – SOAP(Simple Object Access Protocol) 26 HO CHI MINH UNIVERSITY OF INDUSTRY Now How Remoting works?     Build Remote Object... Remoting works?     Build Remote Object Build Host/Server application Build client application Create a new instance of remote object by using new  While you do this, Remoting system creates the proxy object of Remotable object  Remoting system receives that call and routes it to the server  It then processes the request and return the result to the proxy, which intern return it to the client application... returns a proxy for the served at the specified location No network traffic until first method call! – Proxy built on client from metadata – Server activates object on first method call 30 HO CHI MINH UNIVERSITY OF INDUSTRY 2 Examples TcpChannel & HttpChannel 31 HO CHI MINH UNIVERSITY OF INDUSTRY ExamplesTcpChannel -Name solution : TcpChannelRemoting It has 3 projects: 1) ProxyObject class Library project... class Library project 2) ServerTier (Winform application) 3) ClientTier (Winform application) See next slide… 32 HO CHI MINH UNIVERSITY OF INDUSTRY Create TcpChannelRemoting solution: Choose Visual Studio Solutions Type name: TcpChannelRemoting 33 HO CHI MINH UNIVERSITY OF INDUSTRY Now, I add a ProxyObject class Library project into this solution Right click on solution / add / New Project 34 HO CHI.. .Remoting in general : HO CHI MINH UNIVERSITY OF INDUSTRY  Clients must connect to servers  Server needs to publish an object • I listen on this TCP channel and that HTTP channel • I have a service called . 1 HO CHI MINH UNIVERSITY OF INDUSTRY .NET Remoting 2 HO CHI MINH UNIVERSITY OF INDUSTRY Net Remoting Definition: • Application which is located. application domain or process can communicate with another by using .Net Remoting. • Net Remoting allows processes to share the objects. It can call the

Ngày đăng: 15/03/2014, 15:20

Từ khóa liên quan

Mục lục

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan