Consume a Web Service or POJO from a COBOL program

Development tools

There are three steps to achieve outbound access to Web Services or POJOs:

Figure 2.3. Service proxy development steps

Service proxy development steps

The LegStar Xml Schema to COBOL Translator takes a WSDL or XML Schema file as input and produces a Mapping XML Schema with COBOL annotations. Alternatively, it can use pure Java objects as input when the target is a POJO rather than a Web Service.

The developer will typically edit the resulting XML schema to adjust such things as COBOL string sizes or maximum array sizes, which cannot always be inferred from XML Schema.

The second step, using the LegStar COBOL Transformers Generator is the same tool used for adapters. The result is a set of java classes, which provides the conversion capabilities from mainframe data to XML, JSON or Java.

The third step, the LegStar Mainframe Service Generator, also used for adapters, is used here to produce a Mainframe Proxy and COBOL CICS sample program. The Mainframe Proxy acts as an intermediary between the mainframe client program and the target Web Service or POJO at runtime. It can be deployed as a Servlet.

The COBOL CICS sample program generated can be used to jump start your own mainframe client programs.

Runtime services

LegStar provides a Mainframe Proxy Runtime to support incoming requests from the mainframe. The HTTP Transport is the only one available at the moment.

On the mainframe side, you can use CICS DFHWBCLI or EXEC WEB API to send the payload to the Mainframe Proxy Runtime. All that is required is that the request is an HTTP POST and that the body is binary (not translated to ASCII) signaled by an application/octet-stream MIME type.

For older versions of CICS without DFHWBCLI or EXEC WEB API, LegStar provides a simple HTTP client API written in C/370.

The CICS program does not directly call the target Web Service/POJO. Rather, the generated Mainframe Proxy receives the request, which is still in host (EBCDIC) format at this stage. Again, no conversion occurs on the host significantly reducing the mainframe footprint of this solution.

Transformation from mainframe format to XML is performed by the LegStar COBOL Binding Runtime.

The request would flow as depicted in the following diagram:

Figure 2.4. Service proxy runtime

Service proxy runtime

The Mainframe Proxy uses the standard JAX-WS Client API to perform the call to the target Web Service. Alternatively, when the target is a POJO, the Proxy invokes the POJO method directly. Observe that in the case of POJOs, there is no need for JAXB at runtime, the only constraint is that the Proxy be able to locate the POJO in the J2EE server classpath.