| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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-5464' && req.method === 'POST') {
- const xmlInquiryResponse = `<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://tempuri.org/">
- <rsp>000</rsp>
- <rspdesc>Request Data Berhasil</rspdesc>
- <data>
- <total_tagihan>500000</total_tagihan>
- <nama_wp>RALIN MS GUMAY</nama_wp>
- <tagihan>450000</tagihan>
- <denda>10000</denda>
- </data>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- const xmlPaymentResponse = `<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://tempuri.org/">
- <rsp>000</rsp>
- <rspdesc>Request Data Berhasil</rspdesc>
- </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(3007, () => {
- console.log('SOAP dummy running at http://localhost:3007/dummy-pemko-5464');
- });
|