.NET Remote Client Object Sample Code: Server-activated Server
A simple console application that demonstrates how to host a server-activated remote object. This application listens for client requests on TCP port 8989. Whenever a Web service or a remote object is generated, a configuration file is also created. Below is a sample of a custom host application using a server-activated remote object and a sample configuration file.
using System;
using System.Runtime.Remoting;
using IVTNO;
namespace IVTNORemoteClient
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
IVTNO.RemoteIVTNO remoteIVTNO = null;
try
{
RemotingConfiguration.Configure("C:\\Program Files\\Attachmate\\EAI\\IMSClient\\samples\\IVTNO\\remote\\IVTNO\\RemoteIVTNOClient.config");
remoteIVTNO = new IVTNO.RemoteIVTNOFactory().createIVTNO();
remoteIVTNO.open();
IVTNO.IVTNOInput.input input = new IVTNO.IVTNOInput.input();
input.INPUT_RCD = new IVTNO.IVTNOInput.input_INPUT_RCD();
input.INPUT_RCD.IN_TRNCODE = "IVTNO";
input.INPUT_RCD.IN_CMD = "DISPLAY";
input.INPUT_RCD.IN_LASTNAME = "LAST1";
input.INPUT_RCD.IN_FIRSTNAME = "";
input.INPUT_RCD.IN_EXTN = "";
input.INPUT_RCD.IN_ZIP = "";
IVTNO.IVTNOOutput.output output = remoteIVTNO.IVTNO(input);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_MSG);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_CMD);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_LASTNAME);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_FIRSTNAME);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_EXTN);
System.Console.WriteLine(output.OUTPUT_RCD.OUT_ZIP);
}
catch (Exception xx)
{
System.Console.Error.WriteLine(xx);
}
finally
{
if ( remoteIVTNO != null )
remoteIVTNO.close();
}
}
}
}
Sample Configuration File: RemoteIVTNOClient.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="IVTNO.RemoteIVTNOFactory, IVTNO" url="tcp://localhost:8989/IVTNO"/>
</client>
<channels>
<channel ref="tcp">
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>