public static void Main()
        {
            ChannelServices.RegisterChannel(new HttpChannel());

            Console.WriteLine("Remoting Sample:");

            Console.WriteLine("Generate a new MyProxy using the Type");
            Type    myType  = typeof(MyHelloService);
            string  myUrl1  = "http://localhost/myServiceAccess.soap";
            MyProxy myProxy = new MyProxy(myType, myUrl1);

            Console.WriteLine("Obtain the transparent proxy from myProxy");
            MyHelloService myService = (MyHelloService)myProxy.GetTransparentProxy();

            Console.WriteLine("Calling the Proxy");
            string myReturnString = myService.myFunction("bill");

            Console.WriteLine("Checking result : {0}", myReturnString);

            if (myReturnString == "Hi there bill, you are using .NET Remoting")
            {
                Console.WriteLine("myService.HelloMethod PASSED : returned {0}", myReturnString);
            }
            else
            {
                Console.WriteLine("myService.HelloMethod FAILED : returned {0}", myReturnString);
            }
        }
Пример #2
0
    public static void Main()
    {
        IClientChannelSinkProvider mySoapClientFormatterProvider = new SoapClientFormatterSinkProvider();
        IClientChannelSinkProvider myClientProvider = new MyServerProcessingLogClientChannelSinkProviderData();

        mySoapClientFormatterProvider.Next = myClientProvider;

        TcpChannel channel = new TcpChannel(null, mySoapClientFormatterProvider, null);

        ChannelServices.RegisterChannel(channel);

        RemotingConfiguration.RegisterWellKnownClientType(typeof(MyHelloService),
                                                          "tcp://localhost:8082/HelloServiceApplication/MyUri");

        MyHelloService myService = new MyHelloService();

        if (myService == null)
        {
            Console.WriteLine("Could not locate server.");
            return;
        }

        // Call remote method.
        Console.WriteLine();
        Console.WriteLine("Calling remote object");
        Console.WriteLine(myService.HelloMethod("Caveman"));
        Console.WriteLine(myService.HelloMethod("Spaceman"));
        Console.WriteLine(myService.HelloMethod("Client Man"));
        Console.WriteLine("Finished remote object call");
        Console.WriteLine();
    }