{"id":87934,"date":"2024-12-12T14:14:03","date_gmt":"2024-12-12T10:44:03","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/how-to-make-middleware-of-soap-api-20o5\/"},"modified":"2024-12-12T14:14:03","modified_gmt":"2024-12-12T10:44:03","slug":"how-to-make-middleware-of-soap-api-20o5","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/how-to-make-middleware-of-soap-api-20o5\/","title":{"rendered":"\u0646\u062d\u0648\u0647 \u0633\u0627\u062e\u062a Middleware of soap api"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang<br \/>\n              \u062f\u0631 \u0632\u06cc\u0631 CRUL OF SAP API \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0633\u0627\u062e\u062a\u0646 \u0645\u06cc\u0627\u0646\u200c\u0627\u0641\u0632\u0627\u0631 API \u0627\u0633\u062a <\/p>\n<p>curl &#8211;location &#8211;request POST &#8216;https:\/\/mwuat.icicibankltd.com\/v1\/api\/peoplesoft\/viewMaritalStatus&#8217; \\&#8211;header &#8216;Content-Type: text\/xml;charset=UTF-8&#8217; \\&#8211;header &#8216;SOAPAction: MarStatusfetch.v1 &#8216; \\&#8211;header &#8216;Cookie: hrmsuat=ffffffff094614af45525d5f4f58455e445a4a421640&#8217; \\&#8211;data-raw &#8216;1200PS_VIEWMS90002346&#8217;<\/p>\n<p>\u0645\u0633\u06cc\u0631\u0647\u0627<\/p>\n<p>  app.post(&#8216;\/viewMaritalStatus&#8217;,controller.uotmauth.viewMaritalStatus)<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u06a9\u0646\u062a\u0631\u0644\u0631<\/p>\n<p>exports.viewMaritalStatus = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    const emplid = req.body.EMPLID;<br \/>\n    console.log(emplid);<br \/>\n    const result = await get_viewMaritalStatus_ResponseXML(emplid);<br \/>\n    console.log(&#8216;results&#8217;, result);<br \/>\n    const response = await encryptResponse({ message: &#8216;success&#8217;, data: result, status: 200 });<br \/>\n    TransactionlogError(req.body.EMPLID, req.originalUrl, &#8221;, &#8221;, &#8216;success&#8217;);<br \/>\n    res.send(response);<br \/>\n  } catch (error) {<br \/>\n    TransactionlogError(req.body.EMPLID, req.originalUrl, req.body, error, &#8216;fail&#8217;);<br \/>\n    handleError(req, res, error);<br \/>\n  }<br \/>\n};<\/p>\n<p>const get_viewMaritalStatus_ResponseXML = async emplid =&gt; {<br \/>\n  const url=&#8221;https:\/\/mwuat.icicibankltd.com\/v1\/api\/peoplesoft\/viewMaritalStatus&#8221;;<\/p>\n<p>  \/\/ SOAP XML Payload<br \/>\n  const xmlPayload = `<br \/>\n1200<br \/>\nPS_VIEWMS<\/p>\n<p>    ${emplid}<\/p>\n<p>`;<\/p>\n<p>  const headers = {<br \/>\n    SOAPAction: &#8216;MarStatusfetch.v1&#8217;,<br \/>\n    &#8216;Content-Type&#8217;: &#8216;text\/xml;charset=UTF-8&#8217;,<br \/>\n  };<\/p>\n<p>  try {<br \/>\n    \/\/ Sending the SOAP Request<br \/>\n    const response = await axiosapi.post(url, xmlPayload, { headers });<\/p>\n<p>    console.log(response);<br \/>\n    console.log(response.data);<br \/>\n    return new Promise((resolve, reject) =&gt; {<br \/>\n      parseString(response.data, { explicitArray: false }, (err, result) =&gt; {<br \/>\n        if (err) {<br \/>\n          console.error(&#8216;Error in parsing XML response:&#8217;, err);<br \/>\n          reject(err);<br \/>\n        } else {<br \/>\n          \/\/ Navigate through the XML structure to get to the SOAP Body<br \/>\n          const data = result[&#8216;XML&#8217;][&#8216;soapenv:Envelope&#8217;][&#8216;soapenv:Body&#8217;];<br \/>\n          console.log(&#8216;datadata:&#8217;, data);<br \/>\n          resolve(data);<br \/>\n        }<br \/>\n      });<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(&#8216;Error in SOAP request:&#8217;, error.message);<br \/>\n    throw new Error(&#8216;Failed to fetch marital status data&#8217;);<br \/>\n  }<br \/>\n};<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<div data-article-id=\"2153245\" id=\"article-body\">\n<p>\u062f\u0631 \u0632\u06cc\u0631 CRUL OF SAP API \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0633\u0627\u062e\u062a\u0646 \u0645\u06cc\u0627\u0646\u200c\u0627\u0641\u0632\u0627\u0631 API \u0627\u0633\u062a <\/p>\n<p><code>curl --location --request POST 'https:\/\/mwuat.icicibankltd.com\/v1\/api\/peoplesoft\/viewMaritalStatus' \\<br \/>--header 'Content-Type: text\/xml;charset=UTF-8' \\<br \/>--header 'SOAPAction: MarStatusfetch.v1 ' \\<br \/>--header 'Cookie: hrmsuat=ffffffff094614af45525d5f4f58455e445a4a421640' \\<br \/>--data-raw '<xml><br \/><messagetype>1200<\/messagetype><proccode>PS_VIEWMS<\/proccode><envelope xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:ici=\"http:\/\/xmlns.oracle.com\/Common\/schemas\/ICI_MAR_STS_ERBOT_REQ.V1\"><\/p>\n<header\/><body><br \/><ici_mar_sts_erbot_req><br \/><emplid>90002346<\/emplid><br \/><\/ici_mar_sts_erbot_req><br \/><\/body><br \/><\/envelope><br \/><\/xml>'<\/code><\/p>\n<p>\u0645\u0633\u06cc\u0631\u0647\u0627<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>  app.post('\/viewMaritalStatus',controller.uotmauth.viewMaritalStatus)\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u06a9\u0646\u062a\u0631\u0644\u0631<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>exports.viewMaritalStatus = async (req, res, next) =&gt; {\n  try {\n    const emplid = req.body.EMPLID;\n    console.log(emplid);\n    const result = await get_viewMaritalStatus_ResponseXML(emplid);\n    console.log('results', result);\n    const response = await encryptResponse({ message: 'success', data: result, status: 200 });\n    TransactionlogError(req.body.EMPLID, req.originalUrl, '', '', 'success');\n    res.send(response);\n  } catch (error) {\n    TransactionlogError(req.body.EMPLID, req.originalUrl, req.body, error, 'fail');\n    handleError(req, res, error);\n  }\n};\n\n\n\nconst get_viewMaritalStatus_ResponseXML = async emplid =&gt; {\n  const url=\"https:\/\/mwuat.icicibankltd.com\/v1\/api\/peoplesoft\/viewMaritalStatus\";\n\n  \/\/ SOAP XML Payload\n  const xmlPayload = `<xml>\n<messagetype>1200<\/messagetype>\n<proccode>PS_VIEWMS<\/proccode>\n<envelope xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:ici=\"http:\/\/xmlns.oracle.com\/Common\/schemas\/ICI_MAR_STS_ERBOT_REQ.V1\">\n<header\/>\n<body>\n  <ici_mar_sts_erbot_req>\n    <emplid>${emplid}<\/emplid>\n  <\/ici_mar_sts_erbot_req>\n<\/body>\n<\/envelope>\n<\/xml>`;\n\n  const headers = {\n    SOAPAction: 'MarStatusfetch.v1',\n    'Content-Type': 'text\/xml;charset=UTF-8',\n  };\n\n  try {\n    \/\/ Sending the SOAP Request\n    const response = await axiosapi.post(url, xmlPayload, { headers });\n\n    console.log(response);\n    console.log(response.data);\n    return new Promise((resolve, reject) =&gt; {\n      parseString(response.data, { explicitArray: false }, (err, result) =&gt; {\n        if (err) {\n          console.error('Error in parsing XML response:', err);\n          reject(err);\n        } else {\n          \/\/ Navigate through the XML structure to get to the SOAP Body\n          const data = result['XML']['soapenv:Envelope']['soapenv:Body'];\n          console.log('datadata:', data);\n          resolve(data);\n        }\n      });\n    });\n  } catch (error) {\n    console.error('Error in SOAP request:', error.message);\n    throw new Error('Failed to fetch marital status data');\n  }\n};\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u062f\u0631 \u0632\u06cc\u0631 CRUL OF SAP API \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0633\u0627\u062e\u062a\u0646 \u0645\u06cc\u0627\u0646\u200c\u0627\u0641\u0632\u0627\u0631 API \u0627\u0633\u062a curl &#8211;location &#8211;request POST &#8216;https:\/\/mwuat.icicibankltd.com\/v1\/api\/peoplesoft\/viewMaritalStatus&#8217; \\&#8211;header &#8216;Content-Type: text\/xml;charset=UTF-8&#8217; \\&#8211;header &#8216;SOAPAction: MarStatusfetch.v1 &#8216; \\&#8211;header &#8216;Cookie: hrmsuat=ffffffff094614af45525d5f4f58455e445a4a421640&#8217; \\&#8211;data-raw &#8216;1200PS_VIEWMS90002346&#8217; \u0645\u0633\u06cc\u0631\u0647\u0627 app.post(&#8216;\/viewMaritalStatus&#8217;,controller.uotmauth.viewMaritalStatus) \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f \u06a9\u0646\u062a\u0631\u0644\u0631 exports.viewMaritalStatus = async &hellip;<\/p>\n","protected":false},"author":2,"featured_media":87935,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-87934","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/87934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=87934"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/87934\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/87935"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=87934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=87934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=87934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}