I am absolutely new to Node Red. I tried going through docs of Node-Red and some other blogs,but unfortunately nothing works
Currently i am having two file one as .html and .js files.
In html files, i have defined configuser and configpass as variable name for username and password field. The other 10 fields will be get displayed only when username and password(labeled as Config Username and Config Password) are not empty.When user will enter this 2 fields i.e username and password(labeled as Config Username and Config Password) then other 10 fields will get be shown.
But, now what i am trying is to pass the dynamic value of username and password from html to js file, i am getting as undefined as output in js file
Please check the attachment file,there i have added as comment next to the code to make clear what exactly i have tried and i was looking out.
Let em know if anything not clear or want some more clarifications.
Thanks for Help and your time.
module.exports = function (RED) {
function SoapConfig(n) {
RED.nodes.createNode(this, n);
this.configuser = n.configuser;
this.configpass = n.configpass;
this.wsdl = n.wsdl;
this.endpoint = n.endpoint;
this.auth = n.auth;
this.user = n.user;
this.pass = n.pass;
this.key = n.key;
this.cert = n.cert;
this.token = n.token;
this.binding = n.binding;
this.method = n.method;
}
RED.nodes.registerType("smp-soap-config", SoapConfig);
console.log("username " + this.configuser);
console.log("password " + this.configpass);
RED.httpAdmin.get("/smpsoap-config", RED.auth.needsPermission('smpsoap-config.read'), function(req,res) {
var util = require('util');
var http = require('http');
console.log("inside get function username " + this.configuser); //this is where trying to retreive the value but gettign as undefined
console.log("inside get function password " + this.configpass); //this is where trying to retreive the value but gettign as undefined
var options = {
host: 'localhost',
port: '8181',
path: '/configweb/rest/6.0/dsaconfigurations',
headers: {
'Authorization': 'Basic ' + new Buffer('configuser' + ':' + 'configuser1').toString('base64')
}
};
var str = '';
callback = function(response) {
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
res.json(str);
});
}
http.request(options, callback).end();
});
RED.httpAdmin.post('/smpsoap-config/:wsdl/:endpoint/:username/:password/:binding', RED.auth.needsPermission('smpsoap-config.write'), function(req,res) {
var http = require('http');
var wsdl = decodeURIComponent(req.params.wsdl);
var endpoint = decodeURIComponent(req.params.endpoint);
var username = decodeURIComponent(req.params.username);
var password = decodeURIComponent(req.params.password);
var binding = decodeURIComponent(req.params.binding);
if(binding === 'undefined') {
var userNameString = username == 'undefined' ? '' : ',"username" :"'+username+'",';
var passwordString = password == 'undefined' ? '' : '"password" :"'+password+'"';
var post_data =
'{'+
'"dsaName":"soap",'+
'"methodName":"getBindings",'+
'"connectionParameters": {'+
'"wsdlURL" : "'+wsdl+'",'+
'"endpointAddress" : "'+endpoint+'"'+
userNameString+
passwordString+
'}'+
'}';
var post_options = {
host: 'localhost',
port: '8181',
path : '/configweb/rest/6.0/executedatasourcemethod',
method : 'POST',
headers : {
'Authorization': 'Basic ' + new Buffer('configuser' + ':' + 'configuser1').toString('base64'),
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Content-Length': post_data.length
}
};
var str = '';
callback = function(response) {
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
res.json(str);
});
}
var post_req = http.request(post_options, callback);
post_req.write(post_data);
post_req.end();
} else {
var userNameString = username == 'undefined' ? '' : ',"username" :"'+username+'",';
var passwordString = password == 'undefined' ? '' : '"password" :"'+password+'"';
var post_data =
'{'+
'"dsaName":"soap",'+
'"methodName":"getAvailableOperations",'+
'"connectionParameters": {'+
'"wsdlURL" : "'+wsdl+'",'+
'"endpointAddress" : "'+endpoint+'"'+
userNameString+
passwordString+
'},'+
'"methodParameters" : [{'+
'"parameterName": "bindingName"'+
'}, {'+
'"parameterValue": "'+binding+'"'+
'}, {'+
'"parameterClass": "java.lang.String"'+
'}'+
']'+
'}';
var post_options = {
host: 'localhost',
port: '8181',
path : '/configweb/rest/6.0/executedatasourcemethod',
method : 'POST',
headers : {
'Authorization': 'Basic ' + new Buffer('configuser' + ':' + 'configuser1').toString('base64'),
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Content-Length': post_data.length
}
};
var str = '';
callback = function(response) {
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
res.json(str);
});
}
var post_req = http.request(post_options, callback);
post_req.write(post_data);
post_req.end();
}
});
}