Returning an Array Listing using Remote Procedure Call

Implementing Array Return in RPC

In this article, we will create, launch, and consume a web service without using VS.NET. We will create a Web Service that will return an ArrayList of students. The code for this web service is attached at the end of the document. The file containing the method to be used as a web service is saved with the extension .asmx.

The web service is thus successfully launched. In order to consume the web service we have to call it from another method residing on the same machine itself or any other machine that supports DOTNET.

We will write a simple program to test and consume this web service. This method will call the web service remote method and will accept an ArrayList of students from it and eventually display them on the console of the client machine.

To access the remote method a local stub file is generated. The stub file is then compiled into a .dll file so that local classes and methods can refer it. Once this .dll file is ready the remote method can be accessed as if we are accessing a local method. The client method is totally unaware that it is calling a remote method. The client method is essentially given an illusion that a local method is being invoked.

The following figure shows the steps involved in generating the stub file and compiling it into a .dll file.

 Stub file

Figure 1: Generating the stub file and compiling it into a .dll file

The following figure shows that the local file TestWebService is compiled by referring to the stub dll file. It also displays the ArrayList of students received from the remote method.

TestWebService

Figure 2: Students Array List received and displayed


Similar Articles