In the VisualAge Organizer window, create a new application by selecting New from the Applications pull-down menu. Name your new application RPCProcClientApp.
In the VisualAge Organizer window, create a new visual part in this application by selecting New from the Parts pull-down menu. Name your new part RPCProcClient.
In the Composition Editor create a window that looks like the following,
using label, text, and push button parts:
Now, add a RPC Proc Dialog part to the free-form surface.
In order to use an RPC Proc Dialog a data record must be defined. VisualAge uses this record to build the data to be sent to the server and to access the data that is received from the server. You can use a record, for example, to map fields in a database, or to pass arrays of data. Since we will be sending string data, we will build a C language .H file that will simply limit the number of characters to be sent.
To build the .H file, enter the following text using your favorite text editor and save the file as simplmsg.h in the directory where VisualAge is installed, or a directory in your INCLUDE path.
/***************************************************************/ /* C Record Structure for sending simple string with VisualAge */ /***************************************************************/ typedef struct { char simpleMessage [20]; char concatenatedMessage [40]; } SIMPLE_MSG;
Now that the .H file is built, you must tell VisualAge to use it when sending or receiving data by doing the following:
Now, whenever the client sends or receives data, VisualAge will treat it as an structure of 60 characters and simpleMsg will appear as a tear-off attribute of the RPC Proc Dialog.
Tear off the simpleMsg attribute of the RPC Proc Dialog and drop it on the free-form surface. Now, tear off the connectionSpec attribute of the RPC Proc Dialog and drop it on the free-form surface. You now have all the visual and nonvisual parts you need to complete the client application.
Open the settings view of the RPC Proc Dialog. On the Program
Information page enter the server's program number and
version. Also enter the procedure number for the server function you
wish to invoke. When you are finished the settings page should look
like this:
On the Network Information page enter the RPC vendor's
name, and the protocol you will use to communicate. The vendor product
must already be installed for RPC to work correctly. Also enter the
name of the server you wish to communicate with. This value can be the
TCP name of the server or its dotted address. When you are finished the
settings page should look like this:
Select OK to accept the changes.
In the Composition Editor, connect the simpleMessage attribute of the simpleMsg part to the object attribute of the input text part. Now, whatever the user types into the multi-line edit will be sent as the data. Now, connect the concatenatedMessage attribute of the simpleMsg part to the object attribute of the output text part. This part will display whatever data the server sends back to the client.
Connect the Close push button's clicked event to the closeWidget action of the window.
When you are finished making the connections, your part will look like this
in the Composition Editor:
The client application is complete, so save the part and close the Composition Editor window.