skip to main content

Web Service option : The Service Bridge facility : Web Service generation at command-line

Web Service generation at command-line
The only action required on the source code is the mapping between Linkage Section data items and Web Service parameters. If no action is taken, the Compiler generates a Web Service parameter for each elementary COBOL data item and the parameter is assumed to be input/output. In this case instead we wish to define the first group item as input, the second as i/o, and the third as output, because the archive record buffer is shared between caller and callee, while the other two parameters are one-way.
This is achieved through ELK Directives. The original Linkage Section code will change from
       01  lnk-op-code             pic x.
           88 lnk-insert           value "I".
           88 lnk-update           value "U".
           88 lnk-read             value "R".
           88 lnk-read-next        value "N".
           88 lnk-read-previous    value "P".
           88 lnk-delete           value "D".
           88 lnk-first            value "F".
           88 lnk-last             value "L".
       01  lnk-song-data.
           05 lnk-sd-id            pic 9(5).
           05 lnk-sd-title         pic x(30).
           05 lnk-sd-length        pic x(5).
           05 lnk-sd-artist        pic x(20).
           05 lnk-sd-album         pic x(30).
           05 lnk-sd-genre         pic x(15).
           05 lnk-sd-label         pic x(30).
           05 lnk-sd-year          pic 9(4).
           05 lnk-sd-authors       occurs 5.
              10 lnk-sd-author     pic x(20).
       01  lnk-return-status.
           05 lnk-status           pic x(2).
              88 lnk-ok            value "OK".
              88 lnk-ko            value "KO".
           05 lnk-file-status      pic x(2).
           05 lnk-status-message   pic x(50).
to
       01  lnk-op-code             pic x.
           88 lnk-insert           value "I".
           88 lnk-update           value "U".
           88 lnk-read             value "R".
           88 lnk-read-next        value "N".
           88 lnk-read-previous    value "P".
           88 lnk-delete           value "D".
           88 lnk-first            value "F".
           88 lnk-last             value "L".
       01  lnk-song-data.
           05 lnk-sd-id            pic 9(5).
           05 lnk-sd-title         pic x(30).
           05 lnk-sd-length        pic x(5).
           05 lnk-sd-artist        pic x(20).
           05 lnk-sd-album         pic x(30).
           05 lnk-sd-genre         pic x(15).
           05 lnk-sd-label         pic x(30).
           05 lnk-sd-year          pic 9(4).
           05 lnk-sd-authors       occurs 5.
              10 lnk-sd-author     pic x(20).
       01  lnk-return-status.
           05 lnk-status           pic x(2).
              88 lnk-ok            value "OK".
              88 lnk-ko            value "KO".
           05 lnk-file-status      pic x(2).
           05 lnk-status-message   pic x(50).
After this quick modification, we can compile the program as follows:
The file compiler.properties should include one or more Library Routines and Utilities Configuration entries. For the moment, we just activate the Sevice Bridge feature. It will generate a SOAP RPC Web Service. So, compiler.properties contains:
At the end of the compilation process, you will find two additional files in your working directory:
soapSONGS.cbl : the bridge program that allows our program to be called as Web Service, and
SONGS.wsdl : the XML descriptor of the service
Refer to the installed sample README file for instructions about the deployment and testing of these items.
We’ve just demonstrated how to create a SOAP Web Service. With the next step, we’re going to generate a REST Web Service instead. To achieve it, change compiler.properties as follows:
Then compile again with the command:
At the end of the compilation process, you will find one additional file in your working directory:
restSONGS.cbl : the bridge program that allows our songs program to be called as REST Web Service.
Refer to the installed sample README file for instructions about the deployment and testing of these items.
An alternative way to activate the Service Bridge facitlity is to set the necessary properties directly in the source code, using the SET Directive. For example:
       PROGRAM-ID. SONGS.
In this case, no specific configuration is required at compile time, so the compile command is just:

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left