Lect17 - Remoting
Lect17 - Remoting
Objectives:
Learn the basics of remoting
Learn the elements required to create a remoting application.
1. Remoting Basics
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(MathClass), //type of Remotable
class
"MyMathServer", //URI
WellKnownObjectMode.SingleCall); //Mode
Console.WriteLine("Press <enter> to exit...");
Console.ReadLine();
}
}
Note here that you need to store the MathClass.dll in the same
folder as the MathServer.exe
Here again, there are three things that the client class must do to
communicate with the remotable class:
RemotingConfiguration.RegisterWellKnownClientType(
typeof(MathClass), //type of Remotable class
"http://localhost:9095/MyMathServer"); //server URI
Note that in both options (i) and (ii), we need the type of the
MathClass for the statements to compile.
soapsuds –url:http://localhost:9095/MyMathServer?wsdl –
oa:MathClass.dll -nowp
In this case, you provide the client with the interface, which
he can then use to create the proxy class.
In the following example, the soapsuds utility is used to
generate the MathClass.dll file at the client side and then
option (i) is used.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
RemotingConfiguration.RegisterWellKnownClientType (
typeof (MathClass), // Remotable class
"http://localhost:9095/MyMathServer" // URL of remotable
class
);