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, 6860👍, 0💬
Popular Posts:
Explain all parts of a deployment diagram? Package: It logically groups element of a UML model. Node...
How To Write a Minimum Atom 1.0 Feed File? - RSS FAQs - Atom Feed Introduction and File Generation I...
What will be printed as the resultof the operation below: int x; int modifyvalue() { return(x+=10); ...
Can event’s have access modifiers ? Event’s are always public as they are meant to serve every one r...
How To Escape Special Characters in SQL statements? - MySQL FAQs - Introduction to SQL Basics There ...