| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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-0263' && req.method === 'POST') {
- const xmlInquiryResponse = `<?xml version="1.0" encoding="utf-8"?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Body>
- <InquiryResponse xmlns="http://H2H-UNSRI/">
- <InquiryResult>
- <billinfo3>218230003345</billinfo3>
- <billinfo6>IMAM LAZIO RIANDA</billinfo6>
- <billinfo8>Pendidikan Sejarah</billinfo8>
- <billinfo9>2018 / Ganjil</billinfo9>
- <totalAmount>2500000</totalAmount>
- <billDetails>nama periode: 2018 / Ganjiltotal tagihan: 2500000\n\n</billDetails>
- <status>
- <Status>
- <errorCode>00</errorCode>
- <errorDescription>sukses</errorDescription>
- <isError>false</isError>
- </Status>
- </status>
- </InquiryResult>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- const xmlPaymentResponse = `<?xml version="1.0" encoding="utf-8"?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Body>
- <PaymentResponse xmlns="http://H2H-UNSRI/">
- <PaymentResult>
- <status>
- <Status>
- <errorCode>00</errorCode>
- <errorDescription>sukses</errorDescription>
- <isError>false</isError>
- </Status>
- </status>
- </PaymentResult>
- </PaymentResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- 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(3059, () => {
- console.log('SOAP dummy running at http://localhost:3059/dummy-ws-spp-0263');
- });
|