| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const http = require("http");
- const server = http.createServer((req, res) => {
- let body = "";
- req.on("data", (chunk) => {
- body += chunk;
- });
- req.on("end", () => {
- const regexReg = /<NS1:register>(.*?)<\/NS1:register>/;
- const regexRek = /<NS1:norek>(.*?)<\/NS1:norek>/;
- let match = body.match(regexReg);
- const register = match ? match[1] : null;
- match = body.match(regexRek);
- const rekening = match ? match[1] : null;
- if (req.url === "/BukaRekening" && req.method === "POST") {
- let xmlInquiryResponse = "";
- xmlInquiryResponse =
- `<?xml version="1.0" encoding="utf-8"?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <BukaRekeningResponse xmlns="http://tempuri.org/">
- <BukaRekeningResult>
- <error>false</error>
- <code>00</code>
- <message>Add/Update rekening register: ` +
- register +
- ` berhasil.</message>
- </BukaRekeningResult>
- </BukaRekeningResponse>
- </soap:Body>
- </soap:Envelope>`;
- res.writeHead(200, { "Content-Type": "text/xml; charset=utf-8" });
- res.end(xmlInquiryResponse);
- } else {
- res.writeHead(404, { "Content-Type": "text/plain" });
- res.end("Not found");
- }
- });
- });
- server.listen(3096, () => {
- console.log(
- "SOAP dummy BPJS TK Individual running at http://0.0.0.0:3096/BukaRekening",
- );
- });
|