This document contains the
release information for the NGWS Hello Serveice sample. You will find the following sections below:
This example shows how to write a typical “Hello
World" application using the remoting services provided by the NGWS
runtime. Despite being a very simple
example, it serves a useful purpose for testing the remoting services
installation when things go wrong, and illustrates a number of vital concepts
used when writing remoting applications.
HelloService is the server side object called by the MyHello client
example.
This sample is located in
the Remoting directory of the NGWS SDK sample directories.
For Example,
the server object is located at:
C:\Program
Files\NGWSSDK\Samples\Remoting\HelloService
And the
client object at:
C:\Program
Files\NGWSSDK\Samples\Remoting\MyHello
All remoting examples can be build at once by
invoking NMAKE from the Remoting directory as follows prior to running
the samples…
·
Change to
the Remoting directory and type NMAKE ALL
For Example:
C:\Program
Files\NGWSSDK\Samples\Remoting\:>NMAKE All
·
Alternatively,
go to the individual client and server directories, and build them
individually.
For Example:
C:\Program
Files\NGWSSDK\Samples\Remoting\HelloService:>NMAKE All
C:\Program Files\NGWSSDK\Samples\Remoting\MyHello:>NMAKE All
Open two command windows. Start the server in one window by entering the following at the
command line
MyHost
-cfg HelloService.cfg
You should get the following output
C:\NGWSSDK\Samples\Remoting\HelloService>MyHost
-cfg HelloService.cfg
MyHost is ready to process remote messages.
Press a key and ENTER: G=GC.Collect, 0=Exit
Start
the client in another command window and enter the following
MyHello
-cfg MyHello.DirectHTTP.cfg
You should get the following output
C:\NGWSSDK\Samples\Remoting\MyHello>MyHello
-cfg MyHello.DirectHTTP.cfg
MyHello Sample
Enter your name:
Type your name and press enter. Here's the output.
Enter your name: Dracula
Calling Hello.HelloMethod with: Dracula
Hello.HelloMethod returned: Hi there Dracula
End
The server process should echo the following to the
command line
Hello.HelloMethod
: Dracula
If this does not happen, the application is not
working properly. It is therefore
important to check if the server echoed the text passed to it. What does this mean? It is possible for the application to fail
and still appear to work. When you call
a method on a remote object, the COM runtime
attempts to find remote object and call the required method on it. If it does not find the remote object, it searches
the current path and if found, instantiates the object from there. All these examples are linked to the server
dll when the client is built, therefore the server DLL is in the same directory
as the client. When you run the client
and the server is found on the network, a local copy is executed. When this happens, you don't see the output
the server echoes to the console.
It
is also possible to access the server object through Internet Information
Server using HTTP. First we have to
tell IIS about our object by setting up a Virtual Root as follows:
Since the object will automatically be instantiated via the
ASP framework, we don't have to start the server app when using normal HTTP.
Run the client by entering the following
MyHello -cfg MyHello.cfg
The client examples should produce exactly the same output
we obtained above. The only difference between
this and the previous example is that we are using a WEB server to publish the
server object and the client gains access to the server object via the WEB
server.
We can also run the client from a WEB browser using ASP+. Start Internet Explorer and enter the
following Address
http://localhost/MyHello/MyHello.aspx
The specified ASP+ page will be loaded that prompts you for
a name. The output is similar to the
previous examples, except that the output is displayed in the browser rather
than the command line. This example
assumes you have already set up the Virtual Root described above.