CICS / WebSphere

Mobilize Your Assets
Having come this far, you will be anxious to connect your mobile device to your new JSON service. If your company is serious about mobile (and whose isn’t?), then you will want to implement a suitable architecture to support your mobile projects. 

IBM Worklight is a mobile application platform that supports multiple mobile operating environments with the simplicity of a single codebase. In addition, IBM Worklight Server offers a middle-tier gateway that lets you easily integrate multiple back-end services from across your enterprise. The combination of IBM Worklight and CICS TS allows you to deploy powerful mobile solutions that exploit the value of your existing enterprise services hosted in CICS.

Mobile to Worklight to CICS
Figure 2 shows the basic flow of a request from a mobile device to IBM Worklight Server and from Worklight Server to CICS. At the bottom left of the diagram, you can see the CICS service. The first three steps outlined previously create all the necessary components to define this callable service. Now we’ll focus on the adapter code that resides in Worklight Server.


Worklight Server uses an adapter concept to interact with back-end services. The client code running on the mobile device makes a call to a procedure defined within an adapter. Procedures are written in JavaScript, making the development of adapter code simple and efficient. Worklight Server provides a set of predefined adapters that support SQL, Cast Iron, Java Message Service (JMS) and HTTP for SOAP and RESTful Web service requests.

Worklight adapters have three basic components:

• An XML file that describes the procedures you want to expose to the client application and its connectivity options. In addition, you can define a custom security test for each procedure.
• A JavaScript file that contains the implementation of your procedure
• Optionally, one or more Extensible Stylesheet Language (XSL) files that can be used to perform transformations on the data returned from the back-end service.

When a client application makes a call to a procedure, the Worklight Server checks if the procedure has been defined with a security test. If it has, and this is the first time the client has been authenticated, the server will invoke the test prior to driving the procedure. If the client has been authenticated on a previous request, then Worklight automatically grants access to the protected procedure. This is a simple, yet powerful, mechanism for authenticating a client prior to it making calls against the back-end server. If your organization uses LDAP to authenticate users, then you can take advantage of the LDAP authentication components supplied with Worklight.

To demonstrate just how easy it is to make a JSON request against a CICS service written in COBOL, lets consider the simple COBOL copybook example in Figure 3. Assuming we’ve performed the three basic steps described earlier to create the required binding files and CICS resources, all we need to know is how to code the request from the adapter that will call the CICS service. We aren’t going to worry about the call from the client into the adapter, although if you want to see how equally easy that is, there’s a list of resources at the end of this article that will take you to the online tutorials for Worklight.

Figure 4 shows our sample adapter code to make a request against our COBOL service. As we mentioned earlier, our adapter code is written in JavaScript, in the form of a JavaScript function. We pass a string into the function that will be passed through to our COBOL application—we aren’t including any validation here; we just want to show the basic steps for making a request.

4 Pages