refactorizar xml

This commit is contained in:
Javi Gallego 2017-04-11 10:03:39 +02:00
parent c56f437fed
commit 0d97923630
3 changed files with 15820 additions and 3 deletions

View File

@ -24,4 +24,17 @@ function replaceFunc (token)
return values[key];
}
function setXml(path,data,callback){
fs.writeFile(__dirname + path,data,{encoding:'utf8'},function(err){
if (err) {
callback(err,null);
return;
}
callback(null);
});
}
exports.setXml = setXml;
exports.getXml = getXml;

View File

@ -1,7 +1,7 @@
var querystring = require("querystring");
var xml2js = require('xml2js');
var soap = require('soap');
var getXml = require('./getXml');
var IOXml = require('./IOXml');
var config = require('./config.json');
function soapClient(xmlFile){
@ -16,7 +16,6 @@ function soapClient(xmlFile){
valueKey: '_'
};
soap.createClient(url,options, function(err, client) {
if (err) {
console.log(err);
@ -25,7 +24,7 @@ function soapClient(xmlFile){
client.setSecurity(new soap.BasicAuthSecurity(config.user,config.pass));
console.log('no entra');
getXml.getXml(xmlFile, function(err, data) {
IOXml.getXml(xmlFile, function(err, data) {
if (err) {
console.log('err');
console.log(err);
@ -48,6 +47,11 @@ function soapClient(xmlFile){
console.log(err.message);
return;
}
var builder = new xml2js.Builder();
var fileContent = builder.buildObject(supply);
IOXml.setXml('/xml_buyer/supplyresponse_getall.xml',fileContent,function(){
console.log('archivo creado');
});
});
});
});

File diff suppressed because it is too large Load Diff