61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
var querystring = require("querystring");
|
|
var xml2js = require('xml2js');
|
|
var soap = require('soap');
|
|
var IOXml = require('./IOXml');
|
|
var config = require('./config.json');
|
|
|
|
function soapClient(xmlFile){
|
|
var url = 'http://services2-acc.floraholland.com/CommercialCustomer/CommercialCustomer_1p5.svc?wsdl';
|
|
var auth = "Basic " + new Buffer(config.user + ":" + config.pass).toString("base64");
|
|
var options =
|
|
{
|
|
wsdl_headers:{
|
|
Authorization: auth
|
|
},
|
|
attributesKey: '$',
|
|
valueKey: '_'
|
|
};
|
|
|
|
soap.createClient(url,options, function(err, client) {
|
|
if (err) {
|
|
console.log(err);
|
|
return;
|
|
}
|
|
|
|
client.setSecurity(new soap.BasicAuthSecurity(config.user,config.pass));
|
|
console.log('no entra');
|
|
IOXml.getXml(xmlFile, function(err, data) {
|
|
if (err) {
|
|
console.log('err');
|
|
console.log(err);
|
|
return;
|
|
}
|
|
var parser = new xml2js.Parser();
|
|
parser.parseString(data, function (err, result) {
|
|
//extractedData = result['config']['data'];
|
|
console.dir(result,{
|
|
showHidden:true,
|
|
depth:null,
|
|
colors:true
|
|
});
|
|
console.log('GetSupply');
|
|
console.log(result);
|
|
console.log(result.SupplyRequest);
|
|
client.GetSupply(result.SupplyRequest,function(err, supply) {
|
|
console.log('last request: ', client.lastRequest)
|
|
if (err) {
|
|
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');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
soapClient('/xml_buyer/supplyrequest_getall.xml'); |