What is Remoting in .Net ?
I was hearing the word for long time but never could understand completely,
was bit afraid too. Only thing that i understood about remoting is that
"Remoting is Distributed Architecture in .net", after giving a few try finally
i am able to implement remoting successfully.
If a person like me can understand remoting, I can tell that
each one of you can become a master of remoting. its really Fun.
So, before i start with a realltime implementation, i would like you to familer with few remoting key concepts.
Three major thing of remoting application are :
1. Remote Object Design and Chanel Registration.
2. Host Server.
3. Atleaset one Client.
any developer can develope any of the above component easily, only the tricks
remain in implementation. how to implement !!
Now let's look at the code sample.
|
|
| Server:
The following code will demonstarte how to start server, all seetings are done in
web.config , in code we just need call the configuration settings |
 | Rmoting server code sample |
| /* Usage : This remote server is designed to process the database interaction through service host, and let all the clients to consume the service
| | 1: *
| | 2: * Written By : Arindam Chakraborty on 8th Oct 2007
| | 3: *
| | 4: * Modified By :
| | 5: * Reason :
| | 6: *
| | 7: */
| | 8:using System;
| | 9:using System.Collections.Generic;
| | 10:using System.Text;
| | 11:using System.Runtime.Remoting;
| | 12:using System.Runtime.Remoting.Channels;
| | 13:using System.Runtime.Remoting.Channels.Tcp;
| | 14:using System.Runtime.Remoting.Channels.Http;
| | 15:using System.Runtime.Serialization.Formatters.Soap;
| | 16:using System.ServiceModel;
| | 17:using System.Net;
| | 18:using COBankDTO;
| | 19:
| | 20:namespace ETigers.Remoting.RemoteServer
| | 21:{
| | 22: public class ServerHandeler
| | 23: {
| | 24:
| | 25: private ServiceHost _host = null;
| | 26:
| | 27:
| | 28: public ServerHandeler()
| | 29: {
| | 30:
| | 31: }
| | 32:
| | 33: public void StartServer()
| | 34: {
| | 35: try
| | 36: {
| | 37: System.Type _type = typeof(ETigers.Remoting.DTO.BusinessExceptionSummary);
| | 38: RemotingConfiguration.RegisterWellKnownServiceType(new WellKnownServiceTypeEntry(_type, "BusinessExceptionSummary.soap", WellKnownObjectMode.Singleton));
| | 39:
| | 40: string _serverConfigPath = System.Configuration.ConfigurationSettings.AppSettings["ServerConfigfile"];
| | 41: RemotingConfiguration.Configure(_serverConfigPath + "web.Config", false);
| | 42:
| | 43: //IBusinessException
| | 44: Console.WriteLine("Remote server started successfully");
| | 45: }
| | 46: catch (Exception ex)
| | 47: {
| | 48: Console.WriteLine("Error occured while starting server");
| | 49: }
| | 50: }
| | 51:
| | 52:
| | 53:
| | 54: }
| | 55:}
| | 56:
| | 57: |
|
|
The following steps demonstrate how to design a configuration file, this step really very important, it also gives a very clear picture about the details of remoting framework under .net, the following file called web.config, thus the remoting service can be hosted on IIS |
 | Rmoting service hosting on IIS |
| <?xml version="1.0" encoding="utf-8" ?>
| | 1:<configuration>
| | 2: <system.runtime.remoting>
| | 3: <application>
| | 4: <channels>
| | 5: <channel ref="http" name="COBRemote">
| | 6: <serverProviders>
| | 7: <provider ref="wsdl" />
| | 8: <formatter ref="soap" typeFilterLevel="Full"/>
| | 9: </serverProviders>
| | 10: </channel>
| | 11: </channels>
| | 12: <service>
| | 13: <wellknown type="COBankDTO.BusinessExceptionHandling.BusinessExceptionSummary, COBankDTO" mode="Singleton" objectUri="BusinessExceptionSummary.soap"/>
| | 14: </service>
| | 15: </application>
| | 16: </system.runtime.remoting>
| | 17: <connectionStrings>
| | 18: <add name="ConnectionString" connectionString="server=14.156.37.21;Initial Catalog=Databasename;User Id=userid;Password=password" providerName="System.Data.OracleClient" />
| | 19: </connectionStrings>
| | 20:</configuration>
| | 21: |
|
|
Asp.net, Ado.net, .Net Remoting, .Net
Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML