const http = require('http'); const server = http.createServer((req, res) => { let body = ''; let hasInquiry = false; let hasPayment = true req.on('data', (chunk) => { body += chunk; }); req.on('end', () => { hasInquiry = /<(\w+:)?Inquiry\b/.test(body); hasPayment = /<(\w+:)?Payment\b/.test(body); if (req.url === '/dummy-ws-spp-0087' && req.method === 'POST') { const xmlInquiryResponse = ` 0 02 2018100608 CINDY LAILATIN FITRIA PGSD Gelombang II Reguler / Reguler CBT Sore IDR 2 SPP :Rp. 4,000,000.00HEREGISTRASI :Rp. 300,000.00 4300000 insert into inquiry (nim, nama, numbill, billid, billcode, billname, billamount, periode, statusbayar, transdatetime, id_teller) values ('2018100608','CINDY LAILATIN FITRIA','2','201811200000201810060801','SPP','SPP ','4000000','20181', '0', now(), '6822');insert into inquiry (nim, nama, numbill, billid, billcode, billname, billamount, periode, statusbayar, transdatetime, id_teller) values ('2018100608','CINDY LAILATIN FITRIA','2','201810600000201810060801','HER','HEREGISTRASI ','300000','20181', '0', now(), '6822'); insert into inquiry (nim, nama, numbill, billid, billcode, billname, billamount, periode, statusbayar, transdatetime, id_teller) values ('2018100608','CINDY LAILATIN FITRIA','2','201811200000201810060801','SPP','SPP ','4000000','20181', '0', now(), '6822');insert into inquiry (nim, nama, numbill, billid, billcode, billname, billamount, periode, statusbayar, transdatetime, id_teller) values ('2018100608','CINDY LAILATIN FITRIA','2','201810600000201810060801','HER','HEREGISTRASI ','300000','20181', '0', now(), '6822'); 2 300,000.00 SPP SPP 201811200000201810060801 4000000 20181 HER HEREGISTRASI AKTIF 201810600000201810060801 300000 20181 false 00 Sukses `; const xmlPaymentResponse = ` 0 0 0 0 false 00 Sukses `; if(hasInquiry) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' }); res.end(xmlInquiryResponse); } else if (hasPayment) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' }); res.end(xmlPaymentResponse); } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not found'); } } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not found'); } }); }); server.listen(3018, () => { console.log('SOAP dummy running at http://localhost:3018/dummy-ws-spp-0087'); });