At this point our remote server is hosted in IIS. It is time
to create a client to test it. We will create a web application in ASP.NET
which will consume or call the functions of remote server.
Create a new ASP.NET web application
Step 1: Open Visual Studio 2005 IDE. Create a class project
as: File >> New >> Web Site.
Choose ASP.NET Web Site in the template. Give the project
name as Client as shown below.
Figure 6: Creating the ASP.NET client application
(remote client)
It will create the Client folder in www.root folder with
default files and folder. You will see in the Client project VS automatically
added two files Defaut.aspx and web.config. Rename file Default.aspx to
Client.aspx.
Step 2: Add reference to the web server interface assembly
(IServer.dll in this example).
In the project menu choose- Website >> Add Reference
>> Browse >> \IServer\IServer\bin\Debug\IServer.dll >> OK.
Step 3: Now implement the Page_Load of the Client.aspx as
given below.
Listing 4: Code for Page_Load in Client page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)_
Handles Me.Load
Dim objRemote As IServer.IServer
'create transperent proxy object
objRemote = CType(Activator.GetObject(GetType(IServer.IServer), _
"http://localhost/server/server.soap"), IServer.IServer)
'Executing remote object function
Response.Write("Time received from Server: " & objRemote.GetTimeFromServer())
End Sub
Build the Client website.