.NET Remote Client Object Sample Code: Client-activated, IIS Hosted, Client

A simple console application that demonstrates how to execute a task via a client-activated remote object. The remote component is hosted in IIS and includes a corresponding configuration file.

using System;
using System.Runtime.Remoting;

// NOTE: Add project reference to IVTNO.DLL
// 1. Project \ Add Reference... menu item
// 2. Use Browse button to find and add DLL.
using IVTNO;

namespace IVTNORemoteClient
{
  /// <summary>
  /// Summary description for Class1.
  /// </summary>
  class Class1
  {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
      IVTNO.RemoteIVTNO remoteIVTNO = null;

      try
      {
        //Configure RemoteIVTNO as a client-activated object 
        //(hosted in IIS)
        RemotingConfiguration.Configure("C:\\Program Files\\Attachmate\\EAI\\IMSClient\\samples\\IVTNO\\remote\\IVTNO\\RemoteIVTNOClient.config");

        //Instantiate the remote object
        remoteIVTNO = new IVTNO.RemoteIVTNO();

        //Prepare the remote object for stateless execution
        remoteIVTNO.open();
                    
        //Set the task inputs
        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 = "";

        //Execute the task
        IVTNO.IVTNOOutput.output output = remoteIVTNO.IVTNO(input);

        //Display the output
        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
      {
        //Clean up
        if ( remoteIVTNO != null )
          remoteIVTNO.close();
      }		
    }
  }
}

Sample Configuration File: RemoteIVTNOClient.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.runtime.remoting>
<!-- Configuration for a client-activated RemoteIVTNO object
 - hosted in IIS.-->
<application>        
<client url="http://localhost/IVTNO">
<activated type="IVTNO.RemoteIVTNO, IVTNO"/>
</client><channels>
<channel ref="http">
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
Related Topics
Bullet Using .NET
Bullet Adding .NET Remotable Objects to .NET Projects
Bullet .NET Deployment Examples
  Attachmate