const http = require('http');
const server = http.createServer((req, res) => {
let body = '';
let hasInquiry = false;
let hasPayment = false
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-mp-0004' && req.method === 'POST') {
const xmlInquiryResponse = `
000
Success
18260811134140
18
9000140040625650097
F
Saifuddin Surya Basunjaya
40040625650097
8500000
Ganjil 2026/2027
SEKOLAH VOKASI
D4-Teknik Listrik Industri
2025
`;
const xmlPaymentResponse = `
000
Success
19260811134157
19
2026-08-11T13:42:00+07:00
9000140040625650097
Saifuddin Surya Basunjaya
40040625650097
8500000
Ganjil 2026/2027
SEKOLAH VOKASI
D4-Teknik Listrik Industri
2025
`;
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(3201, () => {
console.log('SOAP dummy running at http://localhost:3201/dummy-ws-mp-0004');
});