Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 14: CICS Performance, Security and Advanced Topics


CICS Web Services

CICS can act as a web service provider and as a web service requester. This lets old COBOL programs talk to modern applications over HTTP using SOAP or JSON.

Provider and requester

  • As a provider, CICS exposes a COBOL program as a web service. Other systems call it over HTTP.
  • As a requester, a COBOL program calls a web service on another system with EXEC CICS INVOKE.
  • The PIPELINE resource defines how messages are processed, including the message handlers and the WSBind files.
  • The WEBSERVICE resource binds a pipeline to a specific program and its data mapping.

Building a web service

  • Use the DFHLS2WS assistant to generate a WSBind file and copybook from a COBOL data structure.
  • Use the DFHWS2LS assistant to generate a COBOL copybook from an existing WSDL file.
  • Install the PIPELINE, then the WEBSERVICE, then test with a simple SOAP or REST client.
  • CICS also supports JSON directly, which is simpler than SOAP for new services.

Example: calling a web service from COBOL

  • Put the request data in containers on a channel, then INVOKE the web service.
  • WORKING-STORAGE SECTION. 01 WS-ORDER-REQUEST PIC X(200). 01 WS-ORDER-REPLY PIC X(500). 01 WS-RESPONSE PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS PUT CONTAINER('DFHREQUEST') CHANNEL('ORDER-CHAN') FROM(WS-ORDER-REQUEST) FLENGTH(LENGTH OF WS-ORDER-REQUEST) END-EXEC. EXEC CICS INVOKE WEBSERVICE('ORDERSVC') CHANNEL('ORDER-CHAN') OPERATION('getOrder') RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE = DFHRESP(NORMAL) EXEC CICS GET CONTAINER('DFHRESPONSE') CHANNEL('ORDER-CHAN') INTO(WS-ORDER-REPLY) END-EXEC END-IF.
  • 'ORDERSVC' is the installed WEBSERVICE name. DFHREQUEST and DFHRESPONSE are the standard container names.
  • Always check for SOAP faults in the response. A fault means the call reached the server but failed there.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant