Add the bridge code

The project uses a Java class,, that needs to be imported into your project.

This code converts the instance data types from the Web service to types for the COBOL application and do the appropriate initialization for the COBOL application.

  1. In the DynWebTest1 project, right-click on the Java Resources\src folder in Project Explorer, and then click Import > Import.

    This opens the Import dialog box.

  2. Click General > File System.
  3. Click Next.
  4. Click Browse and navigate to <tutorial_source_folder>\DynWebTest1\src\.
  5. Click OK.
  6. Expand src > com > company > project.
  7. Highlight Book.
  8. Check in the right pane.
  9. Click Finish to import the file into the project.
  10. Open in the editor.
  11. Near the top of the file, update the following line with the location of bookfile.dat:
     public static final String BOOK_FILE = "<tutorial_source_folder>\\DataFiles\\bookfile.dat"; 
    Note: Ensure that you use double backslashes so that the path has a valid escape sequence.
  12. Click File > Save.

    The project builds automatically, but in this case the code compiles with errors. This is because some of the types used are in the COBOL projects.


In the outline view are the methods readBook(), nextBook(), deleteBook(), and addBook(), which receive the instance data from the Web service. Each in turn calls a doOperation() method which then converts the data into type of a similar structure for the COBOL application.

The conversion to COBOL is made easier by the types created by SMARTLINKAGE (Details and StatusGroup) allowing a transfer of fields between the Web service types and the ones for the COBOL application. These transfers are done in the methods getDetails() and getBookReturnE().

The final method of note is the overload of doOperation().

static private BookReturnE doOperation(String action, Details details, IRunUnit runUnit)
		     StatusGroup statusGroup = getObject(StatusGroup.class, runUnit);
	     	BookWrapper bookWrapper = getObject(BookWrapper.class, runUnit);		
	     	bookWrapper.BookWrapper(action, details, statusGroup);
	     	return getBookReturnE(details, statusGroup);

The method invoke bookWrapper.BookWrapper(action, details, statusGroup); calls into the COBOL application and was added to the class by the SMARTLINKAGE feature.

The methods of this class can be static as they do not have any instance data and it reduces the number of objects that are created and garbage collected.

Note: Run units are used to isolate one Web service request from another. Each COBOL program, the subprograms it calls, and any resources such as data files are all self-contained within the run unit and separate from other run units using the same programs.

The next step is to update the four methods in the BookLegacySkeleton class to call the appropriate methods in the BookOperation class.