Testing the scenario with a IBM Worklight HTTP adapter

This procedure uses IBM Worklight Studio that is installed on Eclipse. The instructions apply to IBM Worklight Studio v6.1.

Procedure

  1. In a IBM Worklight project, create a new IBM Worklight HTTP adapter named CtgDemoAdapter.
  2. Open the CtgDemoAdapter.xml file in the editor
  3. Add a connections policy with the following settings:
    Table 1. Settings for the connections policy
    Parameter Value
    Protocol http
    Domain <cics tg host name>
    Port 2080
  4. Add a new procedure with the name postEC03.
  5. Close and save CtgDemoAdapter.xml.
  6. Open the CtgDemoAdapter-impl.js file in the editor and add the following function code:
    function postEC03(ec03Data) {
       var request = '{"EC03Operation":{"INPUTDATA": ' + ec03Data +' }}'; 
       var input = {
          method : 'post',
          returnedContentType : 'json',
          path : 'EC03',
          headers : { 'Content-Type' : 'application/json'}, 
          body: { 
             contentType: 'json', 
             content: request.toString()
          } 
       };
       return WL.Server.invokeHttp(input);
    }
  7. To send the request to CICS® TG, right-click the CtgDemoAdapter adapter and select Run As > Invoke Worklight Procedure.
    In the Invoke Worklight Procedure dialog, set the following parameters:
    Table 2. Parameters for Invoke Worklight Procedure
    Parameter Value
    Procedure name postEC03
    Signature postEC03(ec03Data)
    Parameters 'Test data'

Results

A pane with the following response is displayed:
{
   "EC03OperationResponse": {
      "CICSDATETIME": "26\/03\/2014 12:54:03",
      "INPUTDATALENGTH": {
         "inputlength": 9
      },
      "OUTPUTMESSAGE": "Input data was: Test data"
   },
   "isSuccessful": true,
   "responseHeaders": {
      "Content-Length": "146",
      "Content-Type": "application\/json",
      "Date": "Wed, 26 Mar 2014 12:54:07 GMT",
      "X-Powered-By": "Servlet\/3.0"
   },
   "responseTime": 31,
   "statusCode": 200,
   "statusReason": "OK",
   "totalTime": 31
}

You can use the WL.Client.invokeProcedure function call from a IBM Worklight application to call this adapter.