Simple design pattern

The COBOL service program for the web service takes the form of a controller. In the model-view-controller, MVC, web architecture for applications, the controller is the component that receives the GET or POST input and invokes domain objects that contain the business rules that perform a specific task and produce the output.

First, the controller receives the input. Here is the code that does this.

       Preset Section.
           If Not XML-OK Go To Z.


           CALL "C$GetEnv" USING "BIS_FILENAME",

           If not BIS-Exchange-File-Result = 0
               DISPLAY "Could not obtain the BIS Exchange filename"
               STOP RUN.

           Display "BIS Exchange File: " BIS-Exchange-File-Name.

           Perform Process-SOAP-Requests.
           Stop Run.

This is a normal initialization for a BIS service program. The XML Extensions package initializes and the exchange document file that contains the client is found. The dispatcher is PERFORMed.

Tip: The term dispatcher is used in the model-view-controller architecture. The dispatcher code determines what is being requested, and calls the code to perform the request.
Process-SOAP-Requests Section.

               "Method_Namespace"     Method-Namespace-URI.   *> all
           If Not XML-OK Go To Z End-If.
           Call "B_ReadRequest" Giving BIS-Status
           If Not BIS-OK Go To Z.

      *    At this point, the SOAP request payload elements
      *    are available to the application in the exchange file.

           Initialize SOAP-Request-Response.
           Move HTTP-Method-POST To HTTP-Method.
           move Service-URI to SOAP-Address.
           move SOAP-Action-URI to SOAP-Action-Prefix.
           move Method-Namespace-URI to Method-Namespace.
           move Service-Name to Interface-Name.

           XML IMPORT FILE
               SOAP-Request-Response        *> data item to import into
               BIS-Exchange-File-Name       *> import document file name
               "SOAP-Request-Response"      *> model data-name
               "soap_request_to_cobol.xsl". *> stylesheet for transform
           If Not XML-OK Go To Z.
      *    The request has been imported into SOAP-Request-Response

           If HTTP-Method-Is-GET
      *        GET is the HTTP method that is used to obtain WSDL
               Perform Write-WSDL
               Stop Run


The dispatcher code first calls B_ReadRequest, which is a synchronization routine that waits for the BIS request handler (running in the HTTP server) to place the input request document in the exchange file. The request is then imported from the exchange file into the level 01 record area. At this point the dispatcher makes its first decision. If the request is a GET,it creates the WSDL for the web service as the response to the client. Otherwise, the controller knows this is a POST request invoking a method.