const http = require('http'); const fs = require('fs'); const express = require('express') const app = express(); const bodyParser = require('body-parser') const soap = require('soap'); app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.json()) const request = require('ajax-request'); app.use(express.static('vcm')); app.listen(process.env.PORT || 8080); console.log("on 8080"); var url = 'http://193.196.137.147:8990/orchestration/services/SimStadt2MonthlyenergyBalance?wsdl'; var args = { gmlid: 'DENW22AL80000AQv', // an example of a building in Essen DENW22AL700004Lv ----DEBW522AA0003113b---in Stockach cityID: 3,// Essen 3 // Stockach 1 ui: { attic: true, atticHeating: true, basement: true, basementHeating: true, buildingType: "EFH", // other options: "RH", "MFH", "GFH", "HH" flatRoof: true, id: 'DENW22AL80000AQv', // equal with glmid latitude: 50.774414,//51.44679140365339, // an example of a building in Essen longitude: 6.086995,//6.967781962878631, // an example of a building in Essen refurbishment: "statuQuo", // other options: "medium", "advanced" simulationName: "MonthlyEnergyBalance", // just use this value for Heat/Cooling Demand storeyCount: 3, timestep: 1, // dummy integer, not yet integrated but mandatory usageProfile: "Single Family House", // // other options: "Multi Family House" yearOfConstruction: 1946 } }; app.post('/getSimS', function(req,res){ try { const data = req.body; console.log("data ==============") console.log(data.id); args.gmlid = data.id console.log(data[0]); console.log(data[1]); console.log("args ==============") console.log(args); //asdf const returnedTarget = Object.assign(args.ui,data); args.ui = data; args.gmlid = data.id; console.log("returned ==============") console.log(returnedTarget) console.log("args ==============") console.log(args); soap.createClient(url, function(err, client) { client.getMonthlyEnergyBalance(args, function(err, result) { if (err) throw err; console.log(result); // const obj = JSON.parse(result); // console.log(obj) return res.send(result); // res.json(result); // return result; }); }); } catch (err) { console.log('.../getSimS failed!\n' + err); } }); /* ************* WSDL SimStadt (Preston) ************* */ // router.get('/monthlyEnergyBalance', function(req, res) { // var url = 'http://193.196.137.147:8990/orchestration/services/SimStadt2MonthlyenergyBalance?wsdl' // var args = { // gmlid: 'DENW22AL80000AQv', // req.params.gmlID, // cityID: 3,// Essen // ui: { // attic: true, // atticHeating: true, // basement: true, // basementHeating: true, // buildingType: "EFH", // "RH" , "MFH" , "GFH" , "HH" // flatRoof: true, // id: "DENW22AL80000AQv", // latitude: 50.774414, // longitude: 6.086995, // refurbishment: "statuQuo", // "medium", "advanced" // simulationName: "MonthlyEnergyBalance", // storeyCount: 3, // timestep: 1, // dummy integer, not yet integrated but mandatory // usageProfile: "Single Family House", // "Multi Family House" // yearOfConstruction: 1946 // } // }; // soap.createClient(url, function(err, client) { // client.getMonthlyEnergyBalance(args, function(err, result) { // if (err) throw err; // return res.send(result); // }); // }); // });