Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Describe in detail Basic of SAO architecture of Remoting
Describe in detail Basic of SAO architecture of Remoting?
✍: Guest
For these types of questions interviewer expects small and sweet answers. He is basically
looking at what you know about the specific subject. For these type of question this book
will provide detail code which is not necessary to be said during interview. Only the basic
steps and overall brief are enough to convince that you have knowledge about the subject.
Even though this question has detail code and answer say only what is needed in interview.
Remoting has at least three sections :-
ã Common Interface which will be shared between them.
ã Server.
ã Client.
First important section is the common interface between Server and
Client.”InterFaceRemoting” project has the interface code. For sample project interface
is very simple with only two methods :- SetValue and GetValue.
Public Interface InterFaceRemoting Sub SetValue(ByVal value As String) Function GetValue() As String End Interface Second important section is the server.In this sample server is using HTTP channel and the server object is singleton. Imports System Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels.Http Imports System.Runtime.Remoting.Channels Imports InterFaceRemoting Public Class RemotingServer Inherits MarshalByRefObject Implements InterFaceRemoting.InterFaceRemoting Private strData As String Public Function GetValue() As String Implements InterFaceRemoting.InterFaceRemoting.GetValue Return strData End Function Sub New() strData = “testing..” End Sub Public Sub SetValue(ByVal value As String) Implements InterFaceRemoting.InterFaceRemoting.SetValue strData = value End Sub End Class Module ModuleRemotingStartUp Sub Main() Dim objHttpChannel As HttpChannel Console.WriteLine(“Server Started....”) objHttpChannel = New HttpChannel(1234) ChannelServices.RegisterChannel(objHttpChannel) RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer), “RemoteObject”, WellKnownObjectMode.Singleton) Console.WriteLine(“Server registered and listening waiting for clients...”) Console.ReadLine() End Sub End Module
Following is detail explanation :-
ã Channel object is created and registered.
Following is the code.
Dim objHttpChannel As HttpChannel
Console.WriteLine(gServer Started....h)
objHttpChannel = New HttpChannel(1234)
ChannelServices.RegisterChannel(objHttpChannel)
ã Server then hosts the object so that client can connect to it. This is the time
when we specify what mode the server object will be created i.e. Singleton or
SingleCall. This is done by the following below given code. Note in sample weare hosting the server object in singleton mode that means that the same object
will be shared between all clients. Also note the server object is implementing
“InterFaceRemoting” and inheriting from “MarshalByRefObject”.
RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer),
“RemoteObject”, WellKnownObjectMode.Singleton)
Now comes the final section that is third section the client which will connect to this
hosted remoting object.
Following is a detail explanation of client code :-
ã First we create the channel i.e. HTTP. Note whatever channel the server is
using same will be used by the client.
ChannelServices.RegisterChannel(objHttpChannel)
ã As said before the common interface i.e.gInterFaceRemotingh will be used
to communicate with client.
ã After that we can get the server object reference using following code
objRemoting = CType(Activator.GetObject(GetType(InterFaceRemoting.InterFaceRemoting),
ghttp://localhost:1234/RemoteObjecth), InterFaceRemoting.InterFaceRemoting)
ã Then the client can make method call as if the object is local. But actually the
object is a proxy.
Console.WriteLine(“Value on server :- “ & objRemoting
2007-10-23, 4794👍, 0💬
Popular Posts:
What is the main difference between a Vector and an ArrayList? Java Vector class is internally synch...
Describe in detail Basic of SAO architecture of Remoting? For these types of questions interviewer e...
How To Control Horizontal Alignment? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells By...
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise ...
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the cha...