Forum Discussion
If you just want to do the POST and do something with the data you can use iRulesLX. It could look like something like this. Please note, that this is just an example. This code is not tested and will need probably need some modification to fit your needs.
iRule:
when SOME_EVENT {
set var1 "var1"
set var2 "var2"
set var3 "var3"
set rpc_handle [ ILX::init xml_plugin ext_xml ]
if {[ catch { ILX::call $rpc_handle sendXML $var1 $var2 $var3 } result ] } {
log local0. "sendXML failed, ILX failure: $result"
return
}
do something with the result
log local0. "Result: $result"
}
iRuleLX
const http = require("http");
var f5 = require("f5-nodejs");
var ilx = new f5.ILXServer();
ilx.addMethod('sendXML', function(req, res) {
var var1 = req.params()[0];
var var2 = req.params()[1];
var var3 = req.params()[2];
var postData = ' ... ';
var options = {
hostname: 'cnsvwshvm01023.csvw.com',
port: 80,
path: '/cmit/services/dataService.dataServiceHttpSoap11Endpoint/',
method: 'POST',
headers: {
'Content-Type': 'text/xml',
'Content-Length': postData.length,
}
};
var request = http.request(options, (response) => {
response.on('data', (d) => {
/* data received, maybe do something with the data */
return res.reply('successful');
});
});
request.on('error', (e) => {
console.log(e);
return res.reply('failed');
});
request.write(postData);
request.end();
});
ilx.listen();
Nikoolayy1
Jan 22, 2023MVP
That is great and if Content-Type is changed to something like
application/json
then also REST calls probably could be send as I see no issues! Just postData should also be json not xml.