1 // ////////////////////////////////////////////////////////
2 // Lecture on the CORBA Component Model, summer term 2003
3 // Assignment 7, Stephan Brumme, 702544
4 //
5 // Microsoft .NET client that calls a remote "reverse" operation
6 //
7
8 // for console output
9 using System;
10
11 // remoting
12 using System.Runtime.Remoting;
13 using System.Runtime.Remoting.Channels;
14 using System.Runtime.Remoting.Channels.Tcp;
15
16 // reverse operation
17 using ReverseAPI;
18
19
20 namespace Aufgabe7
{
21 /// <summary>
22 /// Encapsulates the Main method
23 /// </summary>
24 class Client
{
25 static void Main()
26 {
27 // catch any RemoteException
28 try
{
29 // request an available TCP based channel
30 ChannelServices.RegisterChannel(new TcpClientChannel());
31
32 // create a proxy for the remote object
33 Reverser proxy = (Reverser)Activator.GetObject(typeof(Reverser), "tcp://localhost:8421/ReverserServer");
34
35 // failed ?
36 if (proxy == null)
37 {
38 Console.WriteLine("Invalid reference.");
39 return;
40 }
41
42 // actually invoke the proxy
43 Console.WriteLine("Reversing the string \"Microsoft .NET===>\<===": \"" + proxy.reverse("Microsoft .NET") + "===>\<==="");
44 }
45 catch (RemotingException)
46 {
47 // something went wrongs
48 Console.WriteLine("Server not found.");
49 }
50 }
51 }
52 }
53