9.4. The Client
Now that the server is running, it's time to talk about building the client. The million dollar question is how the client will get the type information for ServerInfo. Directly referencing the ServerInfo assembly is one option, but not a realistic one, so it will not be considered. It doesn't take an active imagination to foresee the problems that can occur. Instead, this section examines a few techniques for consuming remote objects that allow the implementation to change without affecting the client.
The .NET Framework SDK ships with a utility called SoapSuds.exe that can generate a proxy object the client can use. SoapSuds.exe will even generate the source code for the proxy (but only in C#). Just point it to the URL of the remote object, link to the client shown in Example 9-7, and run. The HTTPchannel must be specified along with the port that was given to the server.
The following command creates a proxy object (with C# source) to the Singleton version of ServerInfo:
soapsuds -url:http://192.168.1.100:1970/RemotingTest/ ServerInfo.rem?wsdl -oa:ServerInfoProxy.dll -gc
Example 9-7. Client for Remote Object Server
'Remote Object Client ' 'Compile: 'vbc /t:exe /r:system.dll /r:System.Runtime.Remoting.dll '/r:ServerInfoProxy.dll remoteclient.vb ' Imports System Imports ObjectServerSpace Public Class Client Public Shared Sub Main( ) Try Dim si As New ServerInfo( ) If Not (si Is Nothing) Then Console.WriteLine(si.MachineName) Console.WriteLine(si.IPAddress) ...