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-0001' && req.method === 'POST') { const xmlInquiryResponse = ` 360 25/561563/EK/25744 Axel Hernanda S1 AKUNTANSI SPP:9200 Periode GENAP 2025 3276061605070002 UKT :Rp. 9,200,000.00 9200000 01 UKT UKT 9200000 False 00 Sukses `; const xmlPaymentResponse = ` 25/561563/EK/25744 Axel Hernanda S1 AKUNTANSI SPP:9200 Periode GENAP 2025 False 01 Invalid Data `; 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(3008, () => { console.log('SOAP dummy running at http://localhost:3008/dummy-ws-spp-0001'); });