1 / 21

.Net Remoting

.Net Remoting. CS-795 Security In Distributed Systems Using .Net Summer 2007 Old Dominion University. Remoting Introduction. The process of programs or components interacting across certain boundaries either different processes or machines

zahina
Télécharger la présentation

.Net Remoting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .Net Remoting CS-795 Security In Distributed Systems Using .Net Summer 2007 Old Dominion University

  2. Remoting Introduction • The process of programs or components interacting across certain boundaries either different processes or machines • Developer Speak - Remoting allows you to pass objects or values across servers in different domains using several different protocols.

  3. Remoting Benefits • Centralized Business Logic • Physical Separation of Layers • Secure Third Party Access

  4. Why use .Net Remoting ? • Objects in different .NET application domains cannot access each other directly • two apps running on same machine even cannot talk to each other without a third party (text files, logs etc) • Enables client code in one application domain to call methods/properties of objects running in another application domain. • .Net analogy to DCOM

  5. .Net Remoting Benefits • Multiple transfer mechanisms – HTTP/TCP • If there is no web server running – put traffic on port 80 • Multiple encodings – SOAP/ Binary (your own-serialization) • .NET Remoting is more flexible (more activation and deployment options) • .NET Remoting is customizable (you can add logging or other features)

  6. .Net Remoting Benefits • .Net Remoting enables you to work with stateful objects • Interface description does not have to be manually coded in any way, as metadata can be extracted from running servers, or from any .Net assembly • One of the major benefits is that it’s centralized around well-known and well-defined standards like HTTP and is directly tied to the .Net Framework

  7. .Net Remoting Basics Client Server Server-Side Object Proxies Dispatcher Formatter Formatter Transport Channel Transport Channel Fig. The .Net Remoting Architecture

  8. .Net Remoting Basics • Different Ways of defining interfaces: • Shared Assembly • Shared Interface or Base Objects • Generated Metadata Assembly (SoapSuds) • Serialization of Data: • Encoding/Decoding of Objects natively supported • Just need to mark such objects with [Serializable] attribute or implement the interface ISerializable • Lifetime Management • Open network connection between client-server • Combined reference counting and pinging mechanisms • Objects get lifetime when created (reset: time-to-live) • Sponsor registered with a server-side object • Multiserver/Multiclient • .Net automatically keeps track of remote object’s origin

  9. .Net Remoting Basics • 2 very different kinds of Objects • Passed by Reference • These objects live on server • Only ObjRef will be passed around • The client usually may not have compiled objects in one of its assemblies, instead only a interface or Base class is available to client • Proxy Object takes care of all remoting tasks

  10. .Net Remoting Basics • 2 very different kinds of Objects • Passed by Value • These objects will be passed over remoting boundaries • Serialized into a string or binary representation and restored as a copy on other side of comm. channel • Each one has its own copy and run independently • Client has to have the compiled object in one of its assemblies • Must support Serialization • [Serializable] class-level attribute or ISerializable interface

  11. First Remoting Application • ICustomerManager: Remote Interface • Customer: Data Object • Server: Implements ICustomerManager interface • Client: Consuming entity • Let us see some code …

  12. MarshalByRefObjects • Categorized into 2 groups: • Server-activated objects (SAOs) • Client-activated objects (CAOs) • SAO: • Comparable to classic stateless Web Services • No message travels to server on reference request by a client • Only when methods are called on this remote reference will the server be notified • Can be either Singleton / SingleCall • How SAO (Singleton/SingleCall) works ? … code helps

  13. MarshalByRefObjects (CAO) • CAO: • An instance of specified class created when • A creation request on the client is encountered using new operator or Activator.CreateInstance() method • An activation message sent to the server • Are stateful objects • Will store state information from one method call to the other

  14. MarshalByRefObjects (CAO) • Cannot use shared interface or assemblies • Have to ship the complied objects to the clients or use SoapSuds to extract metadata out of a running server or a server-side implementation assembly • SoapSuds suggested not be used anymore for .Net to .Net distributed applications • Instead we use a factory design pattern • In this a SAO provides methods to return new instances of the CAO • How CAO (factory design pattern) works ? … code helps

  15. Factory Design Pattern using System; Namespace FactoryDesignPattern { class MyClass {} class MyFactory { public MyClass GetNewInstance() { return new MyClass(); } }

  16. Factory Design Pattern class MyClient { static void Main(string[] args) { //creating using “new” MyClass obj1 = new MyClass(); //creating using a factory MyFactory fac = new MyFactory(); MyClass obj2 = fac.GetNewInstance(); } } }

  17. Managing Life Time of an Object • Lease-based object lifetime • Each server-object is associated with a lease on creation • Lease has time-to-live counter, decremented in certain intervals • In addition, a defined amount of time is added on every method call a client places on remote object • Upon reaching zero time, framework looks for a sponsor registered with the lease.

  18. Managing Life Time of an Object • Lease-based object lifetime • A sponsor is an object running on sever itself, client or any machine reachable via a network • An object subject to garbage collection if • A sponsor decides that the lease will not be renewed • Framework unable to contact any registered sponsors • If a client references time out object, an exception is thrown • System.Runtime.Remoting.Lifetime class

  19. Types of Invocation • Synchronous Calls • Client waits until server finishes processing the request • Asynchronous Calls • Delegates work • One-Way Calls • Framework does not guarantee their execution • Method cannot have return values or out parameters • No exception thrown even if server is down or the method call is malformed • Used in uncritical logging or tracing facilities

  20. .Net Remoting vs Web Services

  21. References • Advanced .Net Remoting – Ingo Rammer & Mario • http://www.thinktecture.com/ • Building Web Services with .Net Remoting and ASP.Net • Group of Authors • .NET Remoting Versus Web Services • http://www.developer.com/net/net/article.php/11087_2201701_1

More Related