var querystring = require("querystring"); var xml2js = require('xml2js'); var soap = require('soap'); var getXml = require('./getXml'); var credential = require('./credential'); function soapClient(xmlFile){ var url = 'http://services2-acc.floraholland.com/CommercialCustomer/CommercialCustomer_1p5.svc?wsdl'; var auth = "Basic " + new Buffer(credential.user + ":" + credential.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(credential.use,credential.pass)); console.log('no entra'); getXml.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; } }); }); }); }); } soapClient('/xml_buyer/supplyrequest_getall.xml');