| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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);
- console.log(hasInquiry);
- console.log(hasPayment);
- console.log(req.url);
- console.log(req.method);
- if (req.url === '/dummy-ws-mp-7788' && 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://tempuri.org/">
- <InquiryResult>
- <BillDetail>
- <BillKey>977887746180906001</BillKey>
- <BillName>Rachmat Sumantri, SH.</BillName>
- <BillAmount>501000</BillAmount>
- <BillStatus>0</BillStatus>
- <BillExpired>2018-09-07 17:18:32</BillExpired>
- </BillDetail>
- <StatusInquiry>0</StatusInquiry>
- <Currency>IDR</Currency>
- <Info1>PAYMENT OPEN</Info1>
- <Info2>Panjar Biaya Perkara</Info2>
- <Info3>PN Jakarta Utara</Info3>
- </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://tempuri.org/">
- <PaymentResult>
- <StatusPayment>
- <IsError>N</IsError>
- <ErrorCode>00</ErrorCode>
- <ErrorDesc>Sukses</ErrorDesc>
- </StatusPayment>
- <Info1>PAYMENT</Info1>
- <Info2>Mochamad Tabhanie, S.H.</Info2>
- <Info3>PN Surabaya</Info3>
- </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(3134, () => {
- console.log('SOAP dummy running at http://localhost:3134/dummy-ws-mpp-778');
- });
|