Upload
joel-cross
View
219
Download
0
Tags:
Embed Size (px)
Citation preview
Develop Distributed Applications using .NET Remoting
Kate GregoryRegional Director
Gregory Consulting [email protected]
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?
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.
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
Architecture and TerminologyIntro to Remoting
Communication between Application Domains Usually Between Servers Replacement for DCOM Low Level Control
Architecture and Terminology Remoting Terminology
Application Domains Channels Formatters Server Activated Objects (Wellknown) Client Activated Objects
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
Architecture and Terminology Formatters
Turn Message Into Stream Binary Soap 1.1 Compliant
Architecture and Terminology .NET to Non-.NET
SOAP 1.1 Specification Http:// Simple Datatypes
int float string
Architecture and Terminology.NET to .NET
Rich Functionality Almost any CLS Object
DataSets Hashtables Custom Objects
Binary Fast
Demo 1
Remoting Concepts
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
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
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
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
Server Activated ObjectsServer Activated Objects
Well-known SingleCall Singleton Marshaling Configuration
Server Activated ObjectsWell-Known
Client Must Know The Endpoint Server Controls Object <wellknown> RegisterWellKnownServiceType()
Server Activated ObjectsSingleCall
Object Created On Each Call One Instance Per Client Request No State Server Farm Friendly mode=“SingleCall”
Server Activated ObjectsSingleton
One Object On Server Has Lifetime
Default 5 Minutes Can Override
Shared Between Multiple Clients
Server Activated ObjectsMarshaling
Marshall by Value Object Serialized Attribute [Serializable] Implement ISerializable
Marshall by Reference Inherit System.MarshalByRefObject Proxy Class
Server Activated ObjectsServer Configuration
Config file<wellknown
mode=“SingleCall” or “Singleton”
type=“type,assembly”
objectUri=“myobject” /> Programmatic
Create Wellknown Type Register
Demo 2
Single Call vs Singleton State
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
Client Activated Objects Client Activated Object (CAO)
Created by Calling Client Client Controls Lifetime
Lease State For Individual Client Tracking Services
Client Activated Objects Client Activation
New() Configuration File <activated />
Activator.CreateInstance() Overloaded Pass In Url, Assembly Attributes
Client Activated Objects Configuration Properties
Config file<activated
type="type,assembly" />
Programmatic UrlAttribute Activator.CreateInstance
Client Activated Objects Properties
Lease Time Default 5 Minutes Set 0 to Infinite
Sponsors Listens from Server Application GetLifeTimeService() Renewal()
Client Activated Objects Tracking
Implement ITrackingHandler DisconnectedObject () MarshaledObject () UnmarshaledObject ()
RegisterTrackingHandler( ITrackingHandler)
Demo 3
Client Activated Objects Lease State
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
Configuration File Configuration
XML Easy To Read Easy To Modify Simple To Code No Need to Recompile
Configuration File Format
<configuration>
<System.Runtime.Remoting>
<application>
</application>
</System.Runtime.Remoting>
</configuration>
Configuration File - Well-known Objects
<service>
<wellknown
type=“Namespace.Class, Assembly” objectUri=“Data” mode=“Singleton” />
</service>
Configuration File - Client Activiated Objects<service>
<activated type=“Namespace.Class, Assembly” />
</service>
Configuration RemotingConfiguration Class
Configure(“configuration file”) Method works for server and client configuration
Configuration Programmatic Configuration
Hide Property Information Required Recompile Dynamic Easy To Deploy
Configuration Programmatic Configuration
Create Channel Register Channel Create Remote Object Register Object with Remoting Configuration
Configuration Programmatic Configuration - Server
ChannelServices.RegisterChannel(new HttpChannel(8080));
RemotingConfiguration.ApplicationName = "Data";
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject.DataAccess),"Data", WellKnownObjectMode.SingleCall);
Configuration Programmatic Configuration - Client
ChannelServices.RegisterChannel(new TcpServerChannel( 6789 ) );
ActivatedServiceTypeEntry obj = new ActivatedServiceTypeEntry( "RemoteObject.DataAccess", "RemoteObject");
RemotingConfiguration.RegisterActivatedServiceType( obj );
Demo 4
Programmatic Configuration
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
Hosting
Application Console Windows Start and Stop by hand Can display or control information
IIS Windows Service
Demo 5
Hosting in IIS Hosting in a Service
Agenda Architecture and Terminology Web Services/DCOM Comparison Server Activated Objects (SAO) Client Activated Objects (CAO) Configuration Hosting Futures
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
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
The (not so distant) future!Indigo
class HelloService { [WebMethod] public String Hello(String Greeting) {
X509CertificateCollection collection = new X509CertificateCollection();IntPtr blob = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CRYPTOAPI_BLOB))); 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
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; }}
10 lines of security code
1,804 lines of reliable
messaging code
25,507 lines of transaction
code
Total count: 27,321
[Confidentiality][Reliability(Guarantees.ExactlyOnce | Guarantees.InOrder)][Service]class HelloService { [TransactionCoupling(
TransactionCouplingOptions.Required)] [ServiceMethod] String Hello(String Greeting) { return Greeting; }}
1 line of security code
1 line of reliable messaging code
1 line of transaction
code
Total count: 3
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