I have a server-side code using .NET Remoting to establish the connection with client. Normally, I understand that using interfaces with objects passed between the client and server is the norm and is a safer alternative, but for the simple communication I am establishing, I do not see the need to go through the trouble of defining the necessary classes and interfaces.
So for the following code, since I'm only returning a string to the client, I don't feel the necessity but some might say otherwise so I'm posting my question here. Should I follow the general convention or stick with the way I'm doing? Also is the code shown below a correct way of establishing a server with remoting?
(Don't ask why I'm using remoting instead of WCF. My boss specifically requested for remoting and I don't know why.)
class HttpServer
{
[STAThread]
public static Boolean startService()
{
HttpChannel channel = new HttpChannel(80);
ChannelServices.RegisterChannel(channel);
Type ddcServerType = Type.GetType("DDCEngine.DDCServer");
RemotingConfiguration.RegisterWellKnownServiceType(ddcServerType, "DDCServer", WellKnownObjectMode.Singleton);
return true;
}
}
public class DDCServer : MarshalByRefObject
{
public string Hello()
{
string r = "hello";
return r;
}
[Description("Sets a new IO Point List in the DDC.")]
public string SetIOPointList(string host, DDCService.pointInformation[] pointList)
{
string result;
DDCService.LGeDDCClient ddc = new DDCService.LGeDDCClient("LGeDDC", host);
try
{
result = ddc.SetIOPoint(pointList);
}
catch (Exception ex)
{
result = ex.ToString();
}
return result;
}