Download presentation
Presentation is loading. Please wait.
Published byJoel Cross Modified over 9 years ago
1
Develop Distributed Applications using.NET Remoting Kate Gregory Regional Director Gregory Consulting Limited kate@gregcons.com
2
What we will cover Introduction to.NET Remoting Not Exhaustive Compare to DCOM and Web Services Configuring.NET Remote Applications Hosting.NET Remote Applications What about Indigo?
3
Who likes DCOM? You know DCOM’s a pain if: You've ever wanted to control the channel or format, or anything else about the DCOM messages. You've ever wanted to trace or log DCOM messages. You've wanted to easily use DCOM over the internet with a variety of clients. You’ve ever wanted to quickly change configuration settings such as ports and channels.
4
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
5
Architecture and Terminology Intro to Remoting Communication between Application Domains Usually Between Servers Replacement for DCOM Low Level Control
6
Architecture and Terminology Remoting Terminology Application Domains Channels Formatters Server Activated Objects (Wellknown) Client Activated Objects
7
Architecture and Terminology Application Domains Process Boundary Provides Isolation Provides Protection Security
8
Architecture and Terminology Channels Transport Data Two Default Formats- http:// or tcp:// Http:// - good for firewalls Tcp:// - high speed, binary Port Agnostic Create Your Own
9
Architecture and Terminology Formatters Turn Message Into Stream Binary Soap 1.1 Compliant
10
Architecture and Terminology.NET to Non-.NET SOAP 1.1 Specification Http:// Simple Datatypes int float string
11
Architecture and Terminology.NET to.NET Rich Functionality Almost any CLS Object DataSets Hashtables Custom Objects Binary Fast
12
Demo 1 Remoting Concepts
13
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
14
Web Services Web Services Any Application IIS WinForm Windows® Service Console Application Multiple Protocols Http:// Tcp:// Custom Binary or Soap Only IIS Only Http:// WSDL Remoting
15
DCOM DCOM Choose Protocol Create Protocol Firewall Friendly Custom Ports Define Protocol Tighter Security Custom IIS NT RPC Protocol Not Firewall Friendly Pings for Lifetime Remoting
16
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
17
Server Activated Objects Well-known SingleCall Singleton Marshaling Configuration
18
Server Activated Objects Well-Known Client Must Know The Endpoint Server Controls Object RegisterWellKnownServiceType()
19
Server Activated Objects SingleCall Object Created On Each Call One Instance Per Client Request No State Server Farm Friendly mode=“SingleCall”
20
Server Activated Objects Singleton One Object On Server Has Lifetime Default 5 Minutes Can Override Shared Between Multiple Clients
21
Server Activated Objects Marshaling Marshall by Value Object Serialized Attribute [Serializable] Implement ISerializable Marshall by Reference Inherit System.MarshalByRefObject Proxy Class
22
Server Activated Objects Server Configuration Config file <wellknown mode=“SingleCall” or “Singleton” type=“type,assembly” objectUri=“myobject” /> Programmatic Create Wellknown Type Register
23
Demo 2 Single Call vs Singleton State
24
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
25
Client Activated Objects Client Activated Object (CAO) Created by Calling Client Client Controls Lifetime Lease State For Individual Client Tracking Services
26
Client Activated Objects Client Activation New() Configuration File Activator.CreateInstance() Overloaded Pass In Url, Assembly Attributes
27
Client Activated Objects Configuration Properties Config file <activated type="type,assembly" /> Programmatic UrlAttribute Activator.CreateInstance
28
Client Activated Objects Lease In DCOM – Ping High Overhead Not Suited for Internet Remoting - Lease-based Mechanism Set Default Lifetime (min, sec, etc..) Sponsors Renew
29
Client Activated Objects Properties Lease Time Default 5 Minutes Set 0 to Infinite Sponsors Listens from Server Application GetLifeTimeService() Renewal()
30
Client Activated Objects Tracking Implement ITrackingHandler DisconnectedObject () MarshaledObject () UnmarshaledObject () RegisterTrackingHandler( ITrackingHandler)
31
Demo 3 Client Activated Objects Lease State
32
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
33
Configuration File Configuration XML Easy To Read Easy To Modify Simple To Code No Need to Recompile
34
Configuration File Format
35
Configuration File - Well-known Objects <wellknown type=“Namespace.Class, Assembly” objectUri=“Data” mode=“Singleton” />
36
Configuration File - Client Activiated Objects
37
Configuration RemotingConfiguration Class Configure(“configuration file”) Method works for server and client configuration
38
Configuration Programmatic Configuration Hide Property Information Required Recompile Dynamic Easy To Deploy
39
Configuration Programmatic Configuration Create Channel Register Channel Create Remote Object Register Object with Remoting Configuration
40
Configuration Programmatic Configuration - Server ChannelServices.RegisterChannel(new HttpChannel(8080)); RemotingConfiguration. ApplicationName = "Data"; RemotingConfiguration. RegisterWellKnownServiceType( typeof(RemoteObject.DataAccess), "Data", WellKnownObjectMode.SingleCall);
41
Configuration Programmatic Configuration - Client ChannelServices.RegisterChannel(new TcpServerChannel( 6789 ) ); ActivatedServiceTypeEntry obj = new ActivatedServiceTypeEntry( "RemoteObject.DataAccess", "RemoteObject"); RemotingConfiguration. RegisterActivatedServiceType( obj );
42
Demo 4 Programmatic Configuration
43
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
44
Hosting Application Console Windows Start and Stop by hand Can display or control information IIS Windows Service
45
Demo 5 Hosting in IIS Hosting in a Service
46
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
47
Other Cool Remoting Tricks Raise an event on the server Handle it in a client Pass a parameter to the handler by reference Get a response from the client that the event was handled Publish-subscribe: server does not managed list of clients
48
Web Services vs. Remoting Web Services XML (SOAP) interfaces to binary objects Text-based; ideal for HTTP etc. Standardized messaging protocol Lightweight, easily deployable and accessible .NET Remoting Binary proxy - stub model Still SOAP 1.1 compatible High performance Binary streams, still configurable over HTTP channel Proprietary .NET required at both ends for straightforward use
49
The (not so distant) future! Indigo
50
Secure, Reliable, Transacted Visual Studio.NET class HelloService { [WebMethod] public String Hello(String Greeting) { X509CertificateCollection collection = new X509CertificateCollection(); IntPtr blob = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CRYPTOAPI_BL OB))); IntPtr data = (IntPtr)((int)blob + Marshal.SizeOf(typeof(CRYPTOAPI_BLOB))); … SeqAckRange range = new SeqAcknRange(id, low, high ); SeqAckRange[] ranges = { range }; ReliableQueue.ProcessAcks( ranges ); … hr = pITxDispenser->BeginTransaction (NULL, ISOLATIONLEVEL_SERIALIZABLE, 0, pITxOptions, &pITransaction); … return Greeting; } 20,379 lines for security 5,988 lines for reliable messaging 25,507 lines for transactions Total count: 56,296 4,442 lines for infrastructure
51
class HelloService { [WebMethod] public String Hello(String Greeting) { foreach ( SecurityToken tok in requestContext.Security.Tokens { X509SecurityToken token = tok as X509SecurityToken } … SeqAckRange range = new SeqAcknRange(id, low, high ); SeqAckRange[] ranges = { range }; ReliableQueue.ProcessAcks( ranges ); … hr = pITxDispenser->BeginTransaction (NULL, ISOLATIONLEVEL_SERIALIZABLE, 0, pITxOptions, &pITransaction); … return Greeting; } Secure, Reliable, Transacted Web Service Enhancements 10 lines of security code 1,804 lines of reliable messaging code 25,507 lines of transaction code Total count: 27,321
52
[Confidentiality] [Reliability(Guarantees.ExactlyOnce | Guarantees.InOrder)] [Service] class HelloService { [TransactionCoupling( TransactionCouplingOptions.Required)] [ServiceMethod] String Hello(String Greeting) { return Greeting; } Secure, Reliable, Transacted Indigo 1 line of security code 1 line of reliable messaging code 1 line of transaction code Total count: 3
53
Advanced web services Secure, reliable, transacted Heterogeneous interoperability Powerful messaging capabilities Programming model extends existing capabilities Simplifies building services Advanced web services Secure, reliable, transacted Heterogeneous interoperability Powerful messaging capabilities Programming model extends existing capabilities Simplifies building services Windows Communication Code Named “Indigo” Network Class Library Internet Connection Firewall Demand Activation and Process Health - IIS PNRP Native WiFi TCP Listener SIP UDP Listener IPC Listener Network Services CLR Serialization Kernel Mode Framework Protocols Filter Engine TCP, UDP IPV4, IPV6 QOS IPSEC HTTP Listener IO Manager Device and File System Drivers … … 802.3 … … 802.11 Connector Communications Manager (Port) Transport Channels (IPC, HTTP, TCP…) Transport Channels (IPC, HTTP, TCP…) Channels (Datagram, Reliable, Peer, …) Policy Engine Message Encoder Channel Security Hosting Environments ASP.NET.container.exe NT Service DllHost Router Topic … … Transactions Federation … … Service Model Instance Manager Context Manager Type Integration Service Methods Declarative Behaviors Transacted Methods Queue Identity and Security System Identity and Security System Transactions Messaging Services System Services
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.