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-4006' && req.method === 'POST') {
const xmlInquiryResponse = `
RALIN MS GUMAY
484416
2025
JL MERAWAN
SAWAH LEBAR BARU
484416
000
Request Data Berhasil
`;
const xmlPaymentResponse = `
603
MIJEN
PT. SARANA PRIMA PERKASA
337415001100804310
true
00
Sukses
154401
ESB453602505
15-01-2026 15:52:27
`;
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(3006, () => {
console.log('SOAP dummy running at http://localhost:3006/dummy-pemko-4006');
});