SOAP 통신 (Node.js)
라이언의 꿀팁백과
103.159.161.129 (토론)님의 2024년 2월 20일 (화) 14:24 판
103.159.161.129 (토론)님의 2024년 2월 20일 (화) 14:24 판
//post to a SOAP API
var http = require('http');
var s_Pan = '378282246310005'; //get the unprotected PAN from the form
var s_DPFormat = 'CC'; //get the data protection Format
var s_Identity = 'user@domain.com'; //get the data protection Format
var s_AuthInfo = 'p3ssw3rd'; //get the data protection Format
//Marshal up a ProtectFormattedData SOAP Mesage: var soapRequest =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vib="http://voltage.com/vibesimple">' + "\n" + ' <soapenv:Header/>' + "\n" + ' <soapenv:Body>' + "\n" + ' <vib:ProtectFormattedData>' + "\n" + ' <dataIn>' + s_Pan + '</dataIn>' + "\n" + ' <format>' + s_DPFormat + '</format>' + "\n" + ' <identity>' + s_Identity + '</identity>' + "\n" + ' <tweak></tweak>' + "\n" + 'SharedSecret ' + "\n" + '' + s_AuthInfo + ' ' + "\n" + ' </vib:ProtectFormattedData>' + "\n" + ' </soapenv:Body>' + "\n" + '</soapenv:Envelope>';
var options = {
hostname: 'voltage-pp-0000.corp.acme.local', port: 8181, path: '/vibesimple/services/VibeSimpleSOAP', method: 'POST', headers: { //'Content-Type': 'text/xml; charset=utf-8', is it this one or the follwing one? 'Content-Type': 'application/soap+xml; charset=utf-8', 'SOAPAction': 'http://voltage.com/vibesimple' }
};
var req = http.request(options, function (res) {
//TODO do something usefull with the response headers: // console.log('headers:\n' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('body:\n' + chunk); });
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
/*
https://uat.riskmanager.cn/WebService/webservices/v3/JPReportService?wsdl
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="https://v3.creditreport.sinotrust.cn"> <soap:Header/>
<soap:Body> <v3:UserLogin> <v3:LoginName>KSURE_test</v3:LoginName> <v3:Password>Experian2023</v3:Password> </v3:UserLogin> </soap:Body>
</soap:Envelope>
*/