Commit 4ebe40cd authored by Marius Wybrands's avatar Marius Wybrands

Crashed commit! Just need a break.

parent 3a440809
const axios = require('axios');
var convert = require('xml-js');
const CircularJSON = require('circular-json');
var constParams = {};
var baseService;
......@@ -26,6 +27,7 @@ module.exports.initWebservice = function(params){
exportService.TabellenExport = function(requestParameter){
console.log("TabellenExport", "Starting");
// force params to be an obj
requestParameter = requestParameter || {};
var params = {};
......@@ -50,11 +52,12 @@ exportService.TabellenExport = function(requestParameter){
params.sachmerkmal3=addDefault(requestParameter.sachMerkmal3);
params.sachschluessel3=addDefault(requestParameter.sachSchluessel3);
params.stand= addStand(requestParameter.stand);
params.auftrag = addAuftrag(requestParameter.sachSchluessel3);
params.auftrag = addAuftrag(requestParameter.auftrag);
params = addLanguage(params);
return new Promise(function (resolve, reject) {
sendRequest('ExportService_2010', params).then(result => {
console.log("Result:", result);
resolve(result['soapenv:Envelope']['soapenv:Body'][params.method + 'Response'][params.method + 'Return']['tabellen']['tabellen']['tabellenDaten']['_text']);
});
})
......@@ -91,10 +94,36 @@ exportService.MerkmalInformation = function(requestParameter){
return new Promise(function (resolve, reject) {
sendRequest('ExportService_2010', params).then(result => {
console.log("Raw", result);
resolve(result['soapenv:Envelope']['soapenv:Body'][params.method + 'Response'][params.method + 'Return']);
});
})
}
exportService.ErgebnisExport = function(requestParameter){
// force params to be an obj
requestParameter = requestParameter || {};
var params = {};
params.method = "ErgebnisExport";
params = addCendentials(params);
params.name = addDefault(requestParameter.name);
params.bereich = addBereich(requestParameter.bereich);
params.format = addDatenFormat(params);
params.komprimieren = addKomprimieren(params);
params = addLanguage(params);
return new Promise(function (resolve, reject) {
sendRequest('ExportService_2010', params).then(result => {
console.log("Raw", result);
resolve(result);
//resolve(result['soapenv:Envelope']['soapenv:Body'][params.method + 'Response'][params.method + 'Return']);
});
})
}
testService.whoami = function() {
return new Promise(function (resolve, reject) {
......@@ -180,6 +209,7 @@ rechercheService.AuftraegeKatalog = function(requestParameter){
return new Promise(function (resolve, reject) {
sendRequest('RechercheService_2010', params).then(result => {
console.log(result);
resolve(result['soapenv:Envelope']['soapenv:Body'][params.method + 'Response'][params.method + 'Return']);
});
})
......@@ -188,23 +218,13 @@ rechercheService.AuftraegeKatalog = function(requestParameter){
var sendRequest = function(service,requestParams){
async function sendRequest(service,requestParams){
return new Promise(function (resolve, reject) {
baseService.get(service, {params: requestParams}).then(response => {
var parsed = responseParser(response, requestParams.method);
resolve(parsed);
})
.catch(function (error) {
console.log("------------------ ERROR ------------------");
console.log(error);
reject(error);
})
.then(function () {
});
});
const result = await baseService.get(service, {params: requestParams});
return result.data;
}
var responseParser = function(response, method) {
var response1 = convert.xml2json(response.data, {compact: true, spaces: 4});
response1 = JSON.parse(response1);
......@@ -224,7 +244,7 @@ var addDefault = function (param) {
return param || "";
}
var addKomprimieren = function (param) {
return param || "true";
return param || "false";
}
var addTransponieren = function (param) {
return param || "false";
......
......@@ -22,6 +22,7 @@
"license": "MIT",
"dependencies": {
"axios": "^0.18.0",
"xml-js": "^1.6.9"
"xml-js": "^1.6.9",
"circular-json": "^0.5.9"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment