Simple design pattern

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

First, the controller has to receive the input. Let's look at the code that does this.

 Preset Section.
    If Not XML-OK Go To Z.
    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.

The code to this point is normal 'reference manual' initialization for a BIS service program. The XML Extensions package is initialized and the exchange document file, which contains the request from the client, is located. The dispatcher (Process-SOAP-Requests) is PERFORMed. (The term 'dispatcher' is used in the model-view-controller architecture. The dispatcher is the code that 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.
      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 will wait until the BIS request handler (running in the HTTP server) has actually placed 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, the WSDL for the web service is created as the response to the client. Otherwise, the controller knows this is a POST request that is invoking a method.