Contents


Overview

Skill Level: Beginner

By using Restify, IBM BPM, and NodeJS we will build a way of accepting mapped parameters in a POST

Ingredients

  • IBM BPM
  • Restify
  • SDK for NodeJS

Step-by-step

  1. Setting up the Server

    1. Download and set up the NodeJS Server as per the instructions from Bluemix
    2. The code for our server
      var restify = require('restify');
      var cfenv = require('cfenv'); // Our CloudFoundry Required code
      var appEnv = cfenv.getAppEnv(); // Part of our Server code required
      var server = restify.createServer();

      //Server Creation
      var server = restify.createServer();

      server.listen(appEnv, function() {
      console.log('%s listening at %s', server.name, server.url);
      });

      server.use(restify.bodyParser({mapParams: true}));

      server.post('/customer/:id', function (req, resp, next) {
      console.log("The request was received");
      console.log("Post received for customer " + req.params.id + ". Thanks!");
      resp.send("Post received for customer " + req.params.id + ". Thanks!");
      return next();
      });
    3. Place that code into our app.js
    4. Open up the package.json file and ensure that dependencies and start are correct
    5. Screen-Shot-2016-12-18-at-7.26.26-PM
    6. cf push
    7. Ensure that the file is sucessfully pushed to bluemix
  2. BPM Set up

    1. Open up any process in the process designer
    2. Create a General Systems Service
    3. Create two variables
      1. result – string
      2. params – map
    4. Drop a piece of server script after the start node
      1. Inside put this code
      2. tw.local.params = new tw.object. Map();
        tw.local.params.put('id', 'zach');
    5. Go into the system toolkit and select implementation then read from http
    6. Drop it after the piece of server script
    7. Put your url, mine for example is 'http://zasdwbackend.mybluemix.net/customer/'
    8. For parameters set it to tw.local.params
    9. Connect all the services
    10. Screen-Shot-2017-01-01-at-11.05.05-PM

     

  3. Test

    Step through your integration service and ensure that it hits the webserver! Congratulations! You sent a POST!

     

    Screen-Shot-2017-01-01-at-11.07.05-PM

Join The Discussion