dummyRPPTutupRekening.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const http = require("http");
  2. const server = http.createServer((req, res) => {
  3. let body = "";
  4. req.on("data", (chunk) => {
  5. body += chunk;
  6. });
  7. req.on("end", () => {
  8. const regex = /<NS1:register>(.*?)<\/NS1:register>/;
  9. console.log(body);
  10. const match = body.match(regex);
  11. const register = match ? match[1] : null;
  12. console.log("register Value:", register);
  13. if (req.url === "/TutupRekening" && req.method === "POST") {
  14. let xmlInquiryResponse = '';
  15. xmlInquiryResponse =
  16. `<?xml version="1.0" encoding="utf-8"?>
  17. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  20. <soap:Body>
  21. <TutupRekeningResponse xmlns="http://tempuri.org/">
  22. <TutupRekeningResult>
  23. <error>false</error>
  24. <code>00</code>
  25. <message>Delete rekening register: ` +
  26. register +
  27. ` berhasil.</message>
  28. </TutupRekeningResult>
  29. </TutupRekeningResponse>
  30. </soap:Body>
  31. </soap:Envelope>`;
  32. res.writeHead(200, { "Content-Type": "text/xml; charset=utf-8" });
  33. res.end(xmlInquiryResponse);
  34. } else {
  35. res.writeHead(404, { "Content-Type": "text/plain" });
  36. res.end("Not found");
  37. }
  38. });
  39. });
  40. server.listen(3097, () => {
  41. console.log(
  42. "SOAP dummy BPJS TK Individual running at http://0.0.0.0:3097/TutupRekening",
  43. );
  44. });