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-pemko-inquiry-4020' && req.method === 'POST') { const xmlInquiryResponse = ` 11 000 Request Data Berhasil 1 177106100800300540 2024 0 177106100800300540 0 0 0 RALIN MS GUMAY JL MERAWAN 0 JL MERAWAN SAWAH LEBAR BARU RATU AGUNG 0 PBB 229 162 0 0 2024-12-31 484416 0 484416 `; const xmlPaymentResponse = ` 12 000 Pembayaran Data Berhasil 1 177106100800300540 2024 0 177106100800300540 0 0 0 RALIN MS GUMAY JL MERAWAN 0 JL MERAWAN SAWAH LEBAR BARU RATU AGUNG 0 PBB 229 162 0 0 2024-12-31 484416 0 484416 `; 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(3001, () => { console.log('SOAP dummy running at http://localhost:3001/dummy-pemko-inquiry-4020'); });