1
0

dummyRPPAddRekening.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 regexReg = /<NS1:register>(.*?)<\/NS1:register>/;
  9. const regexRek = /<NS1:norek>(.*?)<\/NS1:norek>/;
  10. let match = body.match(regexReg);
  11. const register = match ? match[1] : null;
  12. match = body.match(regexRek);
  13. const rekening = match ? match[1] : null;
  14. if (req.url === "/BukaRekening" && req.method === "POST") {
  15. let xmlInquiryResponse = "";
  16. xmlInquiryResponse =
  17. `<?xml version="1.0" encoding="utf-8"?>
  18. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  19. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  21. <soap:Body>
  22. <BukaRekeningResponse xmlns="http://tempuri.org/">
  23. <BukaRekeningResult>
  24. <error>false</error>
  25. <code>00</code>
  26. <message>Add/Update rekening register: ` +
  27. register +
  28. ` berhasil.</message>
  29. </BukaRekeningResult>
  30. </BukaRekeningResponse>
  31. </soap:Body>
  32. </soap:Envelope>`;
  33. res.writeHead(200, { "Content-Type": "text/xml; charset=utf-8" });
  34. res.end(xmlInquiryResponse);
  35. } else {
  36. res.writeHead(404, { "Content-Type": "text/plain" });
  37. res.end("Not found");
  38. }
  39. });
  40. });
  41. server.listen(3096, () => {
  42. console.log(
  43. "SOAP dummy BPJS TK Individual running at http://0.0.0.0:3096/BukaRekening",
  44. );
  45. });