| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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-0037' && 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://unmul/">
- <InquiryResult>
- <billInfo1>2205106012</billInfo1>
- <billInfo2>Syabana Norhayana Istiqomah</billInfo2>
- <billInfo3>PENDIDIKAN JASMANI</billInfo3>
- <billInfo4>KEGURUAN DAN ILMU PENDIDIKAN</billInfo4>
- <billInfo5></billInfo5>
- <billdetail>
- <billDetails>
- <billAmount>2000000</billAmount>
- <billCode></billCode>
- <billName>SPP/Uang Kuliah</billName>
- <billShortName>SPP/Uang Kuliah</billShortName>
- <reference1></reference1>
- <reference2></reference2>
- </billDetails>
- </billdetail>
- <ErrorCode>00</ErrorCode>
- <ErrorDesc>Sukses</ErrorDesc>
- </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://unmul/">
- <PaymentResult>
- <billInfo1></billInfo1>
- <billInfo2></billInfo2>
- <billInfo3></billInfo3>
- <billInfo4></billInfo4>
- <ErrorCode>01</ErrorCode>
- <ErrorDesc>TestFail</ErrorDesc>
- <tes>0</tes>
- </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(3019, () => {
- console.log('SOAP dummy running at http://localhost:3019/dummy-ws-spp-0037');
- });
|