.Net Remoting allows .NET applications to communicate across application domains and machines by making objects on remote machines appear as local objects, utilizing communication channels like TCP and HTTP to serialize and deserialize objects, and server-activated objects on the remote machine that are instantiated based on client requests.
2. Distributed Application
Remote
Distributed systems are Service
Remote
generally more scalable , more Service
robust and increase availability
of services Client Requests
remote process
Common distributed
protocols are:
RPC : Remote
Procedure Calls Server runs the
DCOM : MS Distributed Service/process and
Object Model returns the result
CORBA : Common
Object Request Broker
Architecture Client
RMI : Java Remote
Invocation
Not Secure for Remote
external networks Service
3. Distributed Application
Remote Remote
Objects Objects
Communication
.Net Remoting allows Channel
access to objects Application
placed around a Domain
network.It has: (Assembly)
•Communication channel
•A formatter : This can be Local
Binary encoded or XML Objects
encoded (SOAP)
Remote
Objects
4. Communication Channel
Communication
Channel
Application
Domain
(Assembly) Formatter: Binary
Remote
Fast but not as
Objects
compatible as XML
Local
Objects
Remote
Objects
Formatter: XML
(SOAP)
Highly compatible but
not as fast
5. Remoting Overview
Application
Domain
(Assembly)
Local
Object
Remote
Object
Different Assemblies are
used between Local and
remote Service Typically dll
7. Local Objects
Application
Domain
(Assembly)
Application
Public void myObject (myObjectClass obj)
Pass By Value {
}
Local
Object
Pass By Reference
Public void myObject (ref myObjectClass obj)
Local {
Object }
Within Local
Assembly
9. Remote Object Activation
Client activated objects
These have a finite lease time , Once their lease
time expires they are left for garbage collector.
Each caller would get their copy of the object
Application Remote
Object
Server Activated Object Namespace used for remoting:
System.Net :This include classes
Singleton :All clients get the same
related to the networking elements
instance of the server object. It can of the distributed system
communicate with multiple clients . Life System.Runtime.Remoting : This
time is determined by lease based includes classes for the remote
lifetime (Used for chats, community aspects of the .NET framework , such
networks) as mechanism for remote
Single Call :Is a type of object activation communication between objects
when object is discarded immediately System.Web.Services :This includes
after use. It is stateless. protocols relating to Web services
such as those to HTTP and SOAP
encapsulation
10. Client application domain Marshaling Server application domain
Local Objects passed by reference
or value for local objects . Remote
Object Object
For remote it is not possible
to pass by reference –
Remote objects must be
Client object marshaled
Server Object
Proxy
Remoting System Communication
Remoting System
Channel
Serialization
11. Client application domain Marshaling Server application domain
Remote Object
Local
public class ShowCapital : MarshalByRefObject Remote
{ Object Object
public ShowCapital()
{
}
Client object
public string show ( string country)
{
aCountry capital
}
} Creates dll
Proxy on server ShowCapital()
aCountry capital
Remoting System Communication
Remoting System
Channel
Serialization
12. Client application domain Marshaling Server application domain
Remote
Local Object
Object Object.dll
Access public
methods of
remotable obj
Client object
aCountr capital
y
Proxy ShowCapital()
aountry capital
Remoting System Communication
Remoting System
Channel
Serialisation
13. Client application domain Marshaling Server application domain
Remote
Local Object
Object Object.dll
Client object We need object invocation.
And channel configuration.
Eg. TCP channel 1234 ,
firewalls should allow
Proxy channel ShowCapital()
Remoting System Communication
Remoting System
Channel
Serialisation
14. Channels
• TCP Channel – Faster and more secure
communication. Intended predominantly
for intra-domain communication.
Requires port activation for
communication with external world
• HTTP Channel performed using
HTTP/SOAP protocol. Good for external
communication since it is implemented
over HTTP/HTTPS and most firewalls allow
HTTP calls through.
15. Client application domain TCP Channel
Using System.Runtime.Remoting.Channel.Http
Using System.Runtime.Remoting.Channel.Tcp
Local
Object
TcpChannel channel = new TcpChannel(1234)
ChannelServices.RegisterChannel(channel)
Client object
Makes sure channel is not used
by other apps
Proxy
Channel=1234
Remoting System Communication
Channel
Server activation object
16. Client application domain Activation Server application domain
Remote
Object
Object.dll
Channels map onto TCP
ports..
Client object Standard ports are:
21-FTP
23-TELNET
56-DNS
Proxy 80-www ShowCapital()
110-POP 3
>1024 : developer use
Remoting System Communication
Remoting System
Channel
Serialisation
17. Client application domain Activation
Server Activation is typically used when objects
do not required to maintain their state between
method calls(Single Call ) or where there are
multiple clients who call methods on the same
object instance where the object maintains its
Client object state between function calls (singleton)
Proxy
In a client activated object the
client initiates the object and
manages it for its lifetime.
Remoting System
18. Client application domain Activation
SAO – Single call
What’s the capital of Canada
Ottawa
Client object
Login Name: John
SAO – Singleton
OK
Send email to Bert
Proxy
Ok
CAO- Client
Remoting System Get data Manages
Lifetime
Get data
Delete
19. Registering Remote Object
• Client must have some understanding of
the interface of the remote object.
• So the compiler has check accesses to
remote object
20. ActivationRegistering remote Object mode : this defines the server
object activation, such as SingleCall or Singleton
Client application domain WellKnownObjectMode.SingleCall
Object URI: This is the indicator that the clients
use to locate the object
newClass.ShowCapital
Assembly name: This defines the assembly in
which the class is contained in.
Client object “ShowCapital1”
Type name : This defines the data type of the
remote object.
Typeof(newclass.ShowCapital)
Proxy
Remote
Object
Class Method
Remoting System
newClass.ShowCapitl
Assembly ShowCapital1
21. Activation Object mode : this defines the server activation,
Client application domain such as SingleCall or Singleton
WellKnownObjectMode.SingleCall
Object URI: This is the indicator that the clients
use to locate the object
newClass.ShowCapital
Assembly name: This defines the assembly in
which the class is contained in.
Client object “ShowCapital1”
Type name : This defines that data type of the
remote object.
Typeof(newclass.ShowCapital)
Proxy
Remote
Remote objects are registered using the RegisterWellKnownServiceType
Object
Parameters are (data type , assembly name , activation method) .eg:
RemotingConfiguration.RegisterWellKnownServiceType
Remoting System
(typeof(newClass.ShowCapital),”ShowCapital1”,
newClass.ShowCapital
WellKnownObjectMode.SingleTon
Assembly : ShowCapital1
23. Client side
The remote object will not instantiate itself, the
client is required to initialize it, or call a method.
This is achieved by a client which knows the URI
of the remote object and by registering the
channel it prefers using GetObject :
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel);
ShowCapital sh=(ShowCapital)Activator.GetObject
(typeof(newClass.ShowCapital),
”tcp://localhost:1234/ShowCapital”);
24. Determining data type
Client requires type information about the class
when this client code is compiled.
1- With a reference to the assembly where the class
is stored (use local dll).
2- Using SOAPSUDS tool to extract metadata
directly from the endpoint. SOAPSUDS connects to
the endpoint and extracts the metadata, and
generates an assembly or source code that is then
used in the client compilation.
3-By splitting the remote object into an
implementation and interface class and then use
the interface as a reference when compiling the
client