-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmo.js
More file actions
40 lines (38 loc) · 1.21 KB
/
mo.js
File metadata and controls
40 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
exports.receive = function(type, callback) {
return function(req, res) {
console.log(req.body);
if (req.get('Content-Type') == 'application/xml') {
var xml2js = require('xml2js');
var builder = new xml2js.Builder();
res.set('Content-Type', 'application/xml');
res.send(builder.buildObject({ MSGLST: { MSG: [ { ID: 1, STATUS: "OK" } ] } }));
callback({
event: type,
body: req.body.MSGLST.MSG[0] || req.body.MSGLST.MSG,
'content-type': req.get("Content-Type")
});
} else if (req.get('Content-Type') == "text/xml") {
// SOAP
var xml2js = require('xml2js');
var builder = new xml2js.Builder();
res.set('Content-Type', 'text/xml');
req.send(builder.buildObject({ "soap:envelope": { }}));
callback({
event: type,
body: req.body,
'content-type': req.get("Content-Type")
});
} else {
res.set('Content-Type', 'text/plain');
res.send("0\nOK\n");
callback({
event: type,
body: req.body,
'content-type': req.get("Content-Type")
});
}
}
};
exports.list = function() {
return JSON.stringify(mos);
}