This section explains how to develop CORBA client applications.
The COBOL Project wizard can be used to create CORBA client applications written in COBOL.
Use the COBOL Project wizard to define a target and set up a build environment.
Create a COBOL project by following the procedure below.
Start the Interstage Studio workbench.
Select "File" > "New" > "COBOL Project" from the menu bar. The "New Project" wizard is started.
Specify information in the "New Project" wizard as follows:
On the "COBOL Project" page, specify Basic Project Information.
On the "COBOL Project" page, define a target.
If the target definitions specify a project that uses a precompiler, then specify precompiler linkage information.
On the "Build Environment" page, define the build environment for CORBA clients.
On the "Skeleton Code Selection" page, select "Generate code". In "Available skeleton codes", select the source type to be created.
COBOL Source
Object-Oriented COBOL Source
For details on the COBOL source generation wizard and object-oriented COBOL source generation wizard, refer to "Source Generation Wizard".
Option | Description | |
---|---|---|
Project name | Specify name of the project.(e.g. "CALCLL") | |
Project contents | Specify the save destination for project resources. | |
Create new project in workspace | Saves the project resources to the workspace folder. | |
Create project from existing source | Saves the project resources to a location outside the workspace folder. You can select the resource storage folder by clicking "Browse". |
Option | Description | |
---|---|---|
Target type | Specifies the target type of the COBOL application to be created.
| |
Using the runtime initialization file(COBOL85.CBR) under DLL | If the target type is dynamic link library, then specify whether an initialization file for DLL-specific execution is to be used. | |
Target name | Specifies the file name for the target file (exe/dll) that is created after linkage. (e.g. CALCCL) | |
Application Format | Specifies the type of console (COBOL console/system console) used by the application to create an executable file (exe). | |
Use precompiler | Select this item if you are generating a project that uses a precompiler. | |
Text file encoding(*1) | Select the text file encoding to use when creating a new file for the project. |
*1: To change the "Text file encoding" after the project is created, follow the procedure below:
Select the project. In the "Dependency" view or the "Structure" view, and select "Property" from the context menu. The "Property" dialog box displays.
Select "Resource" in the left pane. The "Resource" page displays.
Select the encoding to be changed in "Text file encoding" of the "Resource" page, and click the "OK" button.
Note
Changing the encoding on the "Info" page at "Text file encoding" does not change the encoding of existing files in the project.
NetCOBOL V10.0.0 or later must be installed in order to build COBOL source files using the text file encoding "UTF-8".
Option | Description |
---|---|
Precompiler command | Specify the name of the command that runs the precompiler. |
Precompiler parameters | Specify parameters of the precompiler command. |
Precompiler source extension | Specify the extension of the precompiler input source file. cobol cob cbl lcai |
Precompiler output source extension | Select the extension of the precompiler output source file. |
Use original source line numbers for error messages | If this item is checked, the COBOL compiler error messages are displayed using the line number in the original source, rather than the line number of the preprocessed source. (The INSDBINF command is invoked (*1).) The default setting is unchecked. |
INSDBINF parameters | Specify parameters of the INSDBINF command that reflects line correction information on an input source for the precompiler to the COBOL source file created by the precompilation. |
*1: For details on the INSDBINF command, refer to "6.2.2 INSDBINF command".
For details on the precompiler linkage information, refer to "6.2.3.2 Setting and changing precompiler link information".
Option | Description | |
---|---|---|
Set build environment for CORBA client | Specifies the build environment when this project is used as a CORBA client. | |
Language(*1) | Specifies the CORBA client description language. | |
Object type(*1) | Specifies the object thread format. | |
Use CDCORBA class(*1) | Specifies the CORBA client creation support class (CDCORBA) provided by Interstage Studio when it is used. |
*1: If "Set build environment for CORBA client" is checked, each optional button and the checkbox become effective.
Option | Description |
---|---|
Do not generate code | When this option is selected, the project is created without the generation of any initial source code. |
Generate code | Creates a project through use of a wizard that generates sample source code. |
Available skeleton codes | If "Generate Code" is selected, "Available skeleton codes" list is enabled to select the initial skeleton code generation. |
The COBOL source file is created using the COBOL source wizard. After the creation, processing is added.
Initialization of CORBA(ORB, Naming Service)
Search the CORBA server object
Invoke the CORBA server application method
This section shows and explains a sample program that receives two parameters from a console, transfers them to a server program, and displays the result on the console.
The server application receives two parameters and returns the result of their addition as a return value. The registered naming service name is assumed to be "Sample::POAintf".
// Module declaration module SAMPLE { // User interface declaration interface CALCULATE_ADD { long CALCULATE(in long param1,in long param2); }; };
The program shown below is used as an example to explain the points on creating object-oriented COBOL programs using static invocation interface.
Points on creating the programs
Code the CONFIGURATION SECTION as follows:
REPOSITORY
COPY CORBA--REP (provided by the CORBA service)
COPY CosNaming--REP (provided by the CORBA service)
COPY IDL-file-name--REP (generated from the IDL file)
CLASS CDCORBA (provided with this product)
SYMBOLIC CONSTANT
COPY CORBA--CONST (provided by the CORBA service)
COPY COSNAMING--CONST.
COPY project-name--CONST (generated from the IDL file)
Define the variables used for ORB initialization in the WORKING-STORAGE SECTION.
Declare the following variables:
W-OBJECT (CORBA-OBJECT type object variable that stores the results of object acquisition by the server application)
W-TARGET (server object type object variable generated from the IDL file): Generated as "module name-interface name"
Code the following types of processing, which can be entered from templates:
ORB initialization
Naming service initialization
Server object acquisition
Target object acquisition
Method invocation by server application(*1)
*1: When you input the method invocation using the template, use the "CORBA Server Objects".
Main program: CALCULATE_ADD_CLIENT.cob
IDENTIFICATION DIVISION. PROGRAM-ID. MAIN. ENVIRONMENT DIVISION. CONFIGURATION SECTION. REPOSITORY. * Standard library for ObjectDirector (for repository declaration) COPY CORBA--REP. * Standard library for naming service (for repository declaration) COPY CosNaming--REP. * Library output by IDL compiler (for repository declaration) COPY USCALCULATE_ADD--REP. * CORBA client development class provided by Interstage Studio CLASS CDCORBA. SPECIAL-NAMES. ARGUMENT-NUMBER IS argument-number ARGUMENT-VALUE IS argument-content SYMBOLIC CONSTANT * Standard library for ObjectDirector (for constant declaration) COPY CORBA--CONST. * Standard library for naming service (for constant declaration) COPY COSNAMING--CONST. * Library output by IDL compiler (for constant declaration) COPY USCALCULATE_ADD--CONST. . DATA DIVISION. WORKING-STORAGE SECTION. 01 L-APL-NAME PIC X(50) VALUE "CALCULATE_ADD_CLIENT". 01 W-OBJECT OBJECT REFERENCE CORBA-OBJECT. 01 W-TARGET OBJECT REFERENCE SAMPLE-CALCULATE_ADD. 01 W-PARAM1 PIC S9(9) COMP-5. 01 W-PARAM2 PIC S9(9) COMP-5. 01 W-RETURN PIC S9(9) COMP-5. 01 L-RETURN PIC S9(9) COMP-5. 01 L-NAME PIC X(128) VALUE "SAMPLE::CALCULATE_ADD". PROCEDURE DIVISION. * ORB initialization INVOKE CDCORBA "GET-ORB" USING L-APL-NAME RETURNING L-RETURN. IF L-RETURN NOT = 0 THEN DISPLAY "ERROR OCCURRED AT GET-ORB" END-IF * Naming service initialization INVOKE CDCORBA "GET-COSNAMING" RETURNING L-RETURN. IF L-RETURN NOT = 0 THEN DISPLAY "ERROR OCCURRED AT GET-COSNAMING" END-IF INVOKE CDCORBA "GET-NAMEOBJ" USING L-NAME RETURNING L-RETURN. IF L-RETURN NOT = 0 THEN DISPLAY "ERROR OCCURRED AT GET-NAMEOBJ" END-IF * Server object acquisition SET W-OBJECT TO NULL. INVOKE CDCORBA "GET-NAMEOBJR" RETURNING W-OBJECT. IF W-OBJECT = NULL THEN DISPLAY "ERROR OCCURRED AT GET-NAMEOBJR" END-IF * Target object acquisition SET W-TARGET TO NULL. INVOKE SAMPLE-CALCULATE_ADD "NARROW" USING W-OBJECT RETURNING W-TARGET. IF W-TARGET = NULL THEN DISPLAY "ERROR OCCURRED AT NARROW" END-IF * Server application method invocation DISPLAY "Enter the first argument:" WITH NO ADVANCING. ACCEPT W-PARAM1. DISPLAY "Enter the second argument:" WITH NO ADVANCING. ACCEPT W-PARAM2. INVOKE W-TARGET "CALCULATE" USING W-PARAM1 W-PARAM2 RETURNING W-RETURN. DISPLAY "result of addition:" W-RETURN. * End of execution EXIT PROGRAM. END PROGRAM MAIN.
A coding sample of a COBOL program using the static invocation interface is shown below. The flow of processing is same as for OOCOBOL although the detailed coding of each type of processing is different. For details on ENVIRONMENT DIVISION, DATA DIVISION, and each type of processing, refer to the "Interstage Application Server Distributed Application Development (CORBA Service Edition)".
Program coding sample(Main program: CALCULATE_ADD_COBCLIENT.cob)
IDENTIFICATION DIVISION. PROGRAM-ID. MAIN. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. ARGUMENT-NUMBER IS ARG-C ARGUMENT-VALUE IS ARG-V SYMBOLIC CONSTANT COPY SYMBOL-CONST IN CORBA. . DATA DIVISION. WORKING-STORAGE SECTION. COPY CONST IN CORBA. * ORB SETTING PARAMETER 01 COPY ULONG IN CORBA REPLACING CORBA-UNSIGNED-LONG BY CURRENT-ARG-C. 01 CURRENT-ARG-V. 02 FILLER OCCURS 6. 03 CURRENT-ARG-V-VALUE USAGE POINTER. 01 APLI-NAME PIC X(30) VALUE "CALCULATE_ADD_CLIENT". 01 TMP-STRING-BUF PIC X(20). 01 COPY LONG IN CORBA REPLACING CORBA-LONG BY ARG-COUNT. * Character string length 01 COPY ULONG IN CORBA REPLACING CORBA-UNSIGNED-LONG BY STRING-LENGTH. * Work pointer 01 TEMP-BUF POINTER. * CORBA-ENVIRONMENT 01 COPY ENVIRONMENT IN CORBA REPLACING CORBA-ENVIRONMENT BY ENV. * CORBA-ORB 01 COPY ORB IN CORBA REPLACING CORBA-ORB BY ORB. * CORBA-BOA 01 COPY BOA IN CORBA REPLACING CORBA-BOA BY BOA. * CORBA-OBJECT (for each type of task) 01 COPY OBJECT IN CORBA REPLACING CORBA-OBJECT BY OBJ. * Exception ID used if an exception is thrown 01 MESS PIC X(30). * Naming Service repository 01 COPY COSNAMING-NAMINGCONTEXT IN CORBA REPLACING COSNAMING-NAMINGCONTEXT BY COS-NAMING. * Naming service name 01 STR-BUF PIC X(30). * For other naming context operations 01 COPY COSNAMING-NAME IN CORBA REPLACING COSNAMING-NAME BY NAME. 01 NAME-A USAGE POINTER. 01 COPY COSNAMING-NAMECOMPONENT IN CORBA REPLACING COSNAMING-NAMECOMPONENT BY NAME-COMPONENT. 01 NAME-COMPONENT-A USAGE POINTER. 01 COPY LONG IN CORBA REPLACING CORBA-LONG BY NUM. * Method return value 01 COPY LONG IN CORBA REPLACING CORBA-LONG BY RET. * Method parameters 01 COPY LONG IN CORBA REPLACING CORBA-LONG BY PARAM1. 01 COPY LONG IN CORBA REPLACING CORBA-LONG BY PARAM2. PROCEDURE DIVISION. * Set server application start parameters. * Set the client application name at the beginning of the start parameters. ACCEPT CURRENT-ARG-C FROM ARG-C. COMPUTE CURRENT-ARG-C = CURRENT-ARG-C + 1. PERFORM VARYING ARG-COUNT FROM 1 BY 1 UNTIL ARG-COUNT > CURRENT-ARG-C IF ARG-COUNT = 1 MOVE APLI-NAME TO TMP-STRING-BUF ELSE ACCEPT TMP-STRING-BUF FROM ARG-V END-IF MOVE FUNCTION LENG (TMP-STRING-BUF) TO STRING-LENGTH CALL "CORBA-STRING-SET" USING CURRENT-ARG-V-VALUE (ARG-COUNT) STRING-LENGTH TMP-STRING-BUF END-PERFORM. SET CURRENT-ARG-V-VALUE (ARG-COUNT) TO NULL. * * ORB initialization * (CORBA-ORB-INIT,CORBA-ORB-BOA-INIT) * MOVE 12 TO STRING-LENGTH. CALL "CORBA-STRING-SET" USING TEMP-BUF STRING-LENGTH FJ-OM-ORB-ID. CALL "CORBA-ORB-INIT" USING CURRENT-ARG-C CURRENT-ARG-V TEMP-BUF ENV ORB. CALL "CORBA-FREE" USING TEMP-BUF. PERFORM ENV-CHECK. MOVE 15 TO STRING-LENGTH. CALL "CORBA-STRING-SET" USING TEMP-BUF STRING-LENGTH CORBA-BOA-OA-ID. CALL "CORBA-ORB-BOA-INIT" USING ORB CURRENT-ARG-C CURRENT-ARG-V TEMP-BUF ENV BOA. CALL "CORBA-FREE" USING TEMP-BUF. PERFORM ENV-CHECK. * * Acquisition of Naming Service repository MOVE FUNCTION LENG ( CORBA-ORB-OBJECTID-NAMESERVICE ) TO STRING-LENGTH. CALL "CORBA-STRING-SET" USING TEMP-BUF STRING-LENGTH CORBA-ORB-OBJECTID-NAMESERVICE. CALL "CORBA-ORB-RESOLVE-INITIAL-REFERENCES" USING ORB TEMP-BUF ENV COS-NAMING. CALL "CORBA-FREE" USING TEMP-BUF. PERFORM ENV-CHECK. * * Search for the server application. * MOVE FUNCTION LENG (STR-BUF) TO STRING-LENGTH. MOVE "SAMPLE::CALCULATE_ADD" TO STR-BUF. CALL "CORBA-STRING-SET" USING IDL-ID OF NAME-COMPONENT STRING-LENGTH STR-BUF. MOVE " " TO STR-BUF. CALL "CORBA-STRING-SET" USING KIND OF NAME-COMPONENT STRING-LENGTH STR-BUF. MOVE 1 TO SEQ-LENGTH OF NAME. MOVE 1 TO SEQ-MAXIMUM OF NAME. MOVE 1 TO NUM. CALL "CORBA-SEQUENCE-COSNAMING-NAMECOMPONENT-ALLOCBUF" USING SEQ-MAXIMUM OF NAME SEQ-BUFFER OF NAME. MOVE FUNCTION ADDR ( NAME ) TO NAME-A. MOVE FUNCTION ADDR ( NAME-COMPONENT ) TO NAME-COMPONENT-A. CALL "CORBA-SEQUENCE-ELEMENT-SET" USING NAME-A NUM NAME-COMPONENT-A. CALL "COSNAMING-NAMINGCONTEXT-RESOLVE" USING COS-NAMING NAME ENV OBJ. MOVE "COSNAMING-NAMINGCONTEXT-RESOLVE" TO MESS. PERFORM ENV-CHECK. * * Server object invocation * Sample name - interface name - operator name * * Addition DISPLAY "Enter the first argument:" WITH NO ADVANCING. ACCEPT PARAM1. DISPLAY "Enter the second argument:" WITH NO ADVANCING. ACCEPT PARAM2. CALL "SAMPLE-CALCULATE-ADD-CALCULATE" USING OBJ PARAM1 PARAM2 ENV RET. PERFORM ENV-CHECK. DISPLAY "result of addition:" RET. * * Post-processing * CALL "CORBA-OBJECT-RELEASE" USING OBJ ENV. CALL "CORBA-OBJECT-RELEASE" USING COS-NAMING ENV. PERFORM ENV-CHECK. CALL "CORBA-FREE" USING SEQ-BUFFER OF NAME. * * Refer to CORBA-ENVIRONMENT information to check whether an exception was thrown. * ENV-CHECK SECTION. EVALUATE TRUE WHEN CORBA-NO-EXCEPTION OF MAJOR OF ENV CONTINUE WHEN CORBA-USER-EXCEPTION OF MAJOR OF ENV DISPLAY "USER-EXCEPTION : " MOVE FUNCTION LENG (MESS) TO STRING-LENGTH CALL "CORBA-STRING-GET" USING IDL-ID OF ENV STRING-LENGTH MESS DISPLAY "ID : " MESS EXIT PROGRAM WHEN CORBA-SYSTEM-EXCEPTION OF MAJOR OF ENV DISPLAY "SYSTEM-EXCEPTION : " MOVE FUNCTION LENG (MESS) TO STRING-LENGTH CALL "CORBA-STRING-GET" USING IDL-ID OF ENV STRING-LENGTH MESS DISPLAY "ID : " MESS EXIT PROGRAM END-EVALUATE. ENV-CHECK-END. EXIT. END PROGRAM MAIN.
When you use the "CORBA Server Object" in the "Template" view, you can add the method invocation.
When using the editor to add the method invocation in the source file, move the cursor to the location at which this processing is to be added and display the "Template" view. Select module name > interface name > method in "CORBA Server Objects" and select "input argument" from the context menu.
The CORBA server objects stored in the Interstage interface repository are displayed as a list.
Templates or categories cannot be added, edited, deleted in CORBA server objects.
The tree structure of the CORBA server object root categories is as follows:
Modules
Modules are shown under the CORBA server object folder.
Interfaces
Interfaces defined for a module is shown under the folder of the module.
Operators
Operators defined for an interface is shown under the folder of the interface.
Note
Individual elements are displayed for CORBA server objects only in an environment where reference to the interface repository is possible. If no elements are displayed for CORBA server objects, check the environment. If the Interstage server is installed, check whether the service required to refer to the interface repository is activated. If the Interstage client is installed, check whether the appropriate server name is set in "Interstage-installation-folder\ODWIN\etc\INITHOST" and whether the server is activated.
Context menu specific to CORBA server objects
Element type | Menu | Description |
---|---|---|
Interface | Insertion of object | Inserts processing for a server object search in the selected interface at the cursor position in the active COBOL editor. |
Operator | Insert | Inserts the operator call at the cursor position in the active COBOL editor. Arguments are inserted as data items named param1 and param2, and the return value is inserted as the data item named "return value". |
Insert with Parameter Value | Displays a dialog box for entering operator arguments and return value data item names, and inserts the operator call at the cursor position in the active COBOL editor. The data item names can be specified in the dialog box. | |
Insert with Multiple Parameter Values | Inserts as many sets of the operator call as specified at the cursor position in the active COBOL editor. A dialog box for entering arguments appears, and data item names can be entered in it. | |
Copy | Copies the operator call to the clipboard. |
Note
"Refresh" can update only the elements under the selected node.
The operation of saving an object to the interface repository is not automatically reflected in CORBA server objects. To do so, execute "Refresh".
To generate a CORBA client application, create stub files and other files required for CORBA clients using the IDL file generated together with the CORBA server application, and register the files in the relevant project.
Start the CORBA Stub File wizard by following the procedure below.
Select "File" > "New" > "Other" from the menu bar. The "New" wizard is started.
Select "COBOL" > "Source" > "CORBA Stub File" in the "New" wizard, and click the "Next" button. The CORBA Stub File wizard is started.
Specify basic information for the CORBA stub file on the "CORBA Stub File Information" page.
Option | Description |
---|---|
IDL file | Specifies the absolute path of the IDL file generated together with the CORBA server application. |
Project | Specifies the project in which the generated stub file is to be registered. |
Language | Specifies the generation language. |
Click the "Finish" button. The stub file is created.
Use the COBOL project wizard. When you check "Set the build environment of CORBA client project" in the "Build Environment" page, the following options are automatically set for the build option.
Build of object-oriented COBOL program
Compile options
LIB(Interstage Application Server install folder\odwin\include\oocob) REPIN(Interstage Application Server install folder\odwin\rep) THREAD(MULTI)or THREAD(SINGLE)
Linker options
Link the following library.
Interstage Application Server install folder\odwin\lib\odoocob.lib Interstage Application Server install folder\odwin\lib\odcnoocob.lib
Build of COBOL program
Compile options
THREAD(MULTI) or THREAD(SINGLE)
Library name
CORBA=Interstage Application Server install folder\odwin\include\cobol
Linker options
Link the following library.
Interstage Application Server install folder\odwin\lib\odcobcbl.lib -- For the single thread Interstage Application Server install folder\odwin\lib\odcobcblmt.lib -- For the multi thread
When setting options other than the above, set them in the "Build" page of the "Property" dialog box. The "Build" page is displayed using the following procedures.
Select CORBA server project from the "Dependence" view or the "Organization" view.
Select "File" > "Property" from the menu bar or select "Property" from the context menu. The "Property" dialog box is displayed.
Select "Build" in left pane. The "Build" page is displayed.
Build of Project
When automatic build is set, the build is executed after saving the COBOL source program. When automatic build is not set, select object-project from the "Dependence" view or the "Structure" view, select "Project" > "Build of Project" from menu bar to execute the build.
See
For details about debug perspective, refer to "Debug Perspective".
When debugging the program, specify "Build Mode" to "Debug". For "Build Mode" procedures, refer to "11.5.1.4.1 Setting the build mode".
Use the COBOL application start-organization to debug a CORBA client application.
Local debug of COBOL application
To perform a local debug of a COBOL application, use the COBOL application start-organization. For details about creating a COBOL application start-organization and starting the debugger, refer to "7.1.3 Starting debugging".
Remote debug of COBOL application
To perform a remote debug of a COBOL application that is built on the server side, use the remote COBOL application start-organization. For details about creating a remote COBOL application start-organization and starting the debugger, refer to the following.
Normal Debugging: "9.6.1.2 Starting the remote debugger"
Attach Debugging:"9.6.2.1 Starting the remote debugger"
After starting the work unit that has deployed the CORBA server application, select the object-project from the "Dependence" view or the "Structure" view, select "Executing" > "Executing(S)" > "COBOL Application" from menu bar, and execute the client application.