I am trying to call a processing rule from a gatewayscript by using the Multistep module. However, I am unable to create a message object from my context to pass it as a parameter to the call rule statement. I am following the examples from the documentation :
multistep module - IBM Documentation
When in debugging mode, I can see that the context.createMessage from the example below is undefined :
var ms = require('multistep');
var fooObj = context.createMessage('foo');
I have tried to create my context by using the session.createContext(), to no avail.
Thank you!
------------------------------
Mathieu Laroche
------------------------------
For some reason I am unable to reply to this thread. Above is my original question, below is my reply Joseph Morgan's answer.
Thank you for your reply. My question was indeed not precise enough.
I want to call a processing rule from a gatewayscrit. I want to use a custom input to pass to the programatically invoked processing rule (custom input, custom headers).
To achieve this, I am following the IBM's documentation :
session object
APIs to manage messages
multistep module
I am trying to do exactly this (excerpt from the multistep module documentation) :
var ms = require('multistep');
var fooObj = context.createMessage('foo');
var barObj = context.createMessage('bar');
fooObj.body.write('HelloWorld');
fooObj.header.set('Header1', 'myHeader');
fooObj.setVariable('Var1', 'myVar');
ms.callRule('ruleAPIGW', 'foo', 'bar', function(error) {
barObj.body.readAsBuffer(function(error, buf) {
var OutputPayload = buf.toString();
var OutputHeaders = barObj.header.get();
var OutputVar1 = barObj.getVariable('Var2');
});
});
However, I never seem to be able to create a "context" variable that has the "createMessage" method available (it is always undefined). So my main problem is creating correctly the context object (I have tried the session.createContext() method without success)
Thank you