Created
December 27, 2019 07:45
-
-
Save mchayapol/55c51d2b38c2ba22885ee0da0f524d4f to your computer and use it in GitHub Desktop.
Pulling VAT registrant data from Thai RD WebService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = 'https://rdws.rd.go.th/serviceRD3/vatserviceRD3.asmx?wsdl'; | |
console.log("RD WebService Test\n", url) | |
var request = require('request'); | |
var fs = require('fs'); | |
var specialRequest = request.defaults({ | |
agentOptions: { | |
ca: fs.readFileSync('./adhq1.cer') //path of CA cert file | |
} | |
}); | |
var requestArgs = { | |
username: 'anonymous', | |
password: 'anonymous', | |
TIN: '0105548115897', | |
ProvinceCode: 0, | |
BranchNumber: 0, | |
AmphurCode: 9 | |
}; | |
// Only ref that works! https://html.developreference.com/article/15047686/Using+Node+to+call+SOAP+Web+Service+over+https | |
var soap = require('soap'); | |
var options = { | |
request: specialRequest | |
} | |
soap.createClient(url, options, function (err, client) { | |
if (err) { | |
console.error(err) | |
return; | |
} | |
// console.log(client) | |
client.Service(requestArgs, function (err, result) { | |
if (err) { | |
console.error(err) | |
return; | |
} | |
let ret = result.ServiceResult | |
for (var key in ret) { | |
if (ret[key]) { | |
let value = ret[key].anyType[0].$value | |
console.log(key,':', value); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment