This document contains the
release information for the NGWS ObjectZone sample. You will find the following sections below:
This example demonstrates a number of features the runtime provides for remote objects. The client constructs an object that requires a string on the constructor, passing "John Smith" as the parameter for the constructor. It then calls the remote method, DoWorkWithNumber, a few times, passing different integers each time. The server keeps a running total of the numbers passed, an returns this number back to the client which is then displayed in the console window.
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\ObjectZone
And the
client object at:
C:\Program
Files\NGWSSDK\Samples\Remoting\MyObject
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\ObjectZone:>NMAKE
All
C:\Program Files\NGWSSDK\Samples\Remoting\MyObject:>NMAKE All
Open two command windows. Start the server in one window by entering the following at the
command line
MyHost
-cfg ObjectZone.cfg
You should get the following output
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
MyObjectApp
-s3 -cfg MyObjectApp.DirectHTTP.cfg
Sample2.bat will execute the command above and is
provided for convenience.
You should get the following output
Stock Remoting Sample
new Baz
Name: John Smith
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 100
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 175
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 125
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 225
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 300
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 250
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 350
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 425
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 375
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 475
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 550
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 500
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 600
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 675
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 625
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 725
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 800
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 750
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 850
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 925
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 875
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 975
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 1050
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 1000
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 1100
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 1175
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 1125
bazDoWorkWithNumber (100)
After DoWorkWithNumber Total Number is 1225
bazDoWorkWithNumber (75)
After DoWorkWithNumber Total Number is 1300
bazDoWorkWithNumber (-50)
After DoWorkWithNumber Total Number is 1250
Sleeping for 45 secondsg
The client process sleeps for 45 seconds before exiting. The server process should echo the following to the command line
Baz
constructor with args - name: John Smith
Change:
100
Total:
100
Change:
75
Total:
175
Change:
-50
Total:
125
Change:
100
Total:
225
Change:
75
Total:
300
Change:
-50
Total:
250
Change:
100
Total:
350
Change:
75
Total:
425
Change:
-50
Total:
375
Change:
100
Total:
475
Change:
75
Total:
550
Change:
-50
Total:
500
Change:
100
Total:
600
Change:
75
Total:
675
Change:
-50
Total:
625
Change:
100
Total:
725
Change:
75
Total:
800
Change:
-50
Total:
750
Change:
100
Total:
850
Change:
75
Total:
925
Change:
-50
Total:
875
Change:
100
Total:
975
Change:
75
Total:
1050
Change:
-50
Total:
1000
Change:
100
Total:
1100
Change:
75
Total:
1175
Change:
-50
Total:
1125
Change:
100
Total:
1225
Change:
75
Total:
1300
Change:
-50
Total: 1250
If this does not happen, the application is
not functioning properly. See the HelloService
example for possible reasons for this.
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
MyObjectApp -s3 -cfg
MyObject.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/MyStock/SimpleQuote.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.
The MyStock directory also contains another ASP+ example. Enter the following address in Internet Explorer
http://localhost/MyObject/MyObject.aspx
We provide 2 additional samples namely Sample3.bat and Sample4.bat in the MyStock directory. Running these is left as an exercise for the reader.