-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson_to_xml_FromDP.js
More file actions
57 lines (51 loc) · 2.55 KB
/
Copy pathjson_to_xml_FromDP.js
File metadata and controls
57 lines (51 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var hm = require('header-metadata');
var nxPrefix = 'man';
var nameSpaceSuffix = 'JSONTOSOAP'
var statuscode = hm.response.statusCode;
var statusdesc;
const nsPrefix = nxPrefix;
const nameSpace = "http://xgw.org.co.il/" + nameSpaceSuffix + "/";
if (statuscode == '200') {
statuscode = '0';
statusdesc = 'Success';
session.input.readAsJSON(function (error, json) {
if (error) {
console.error('@@@AB Input is not valid JSON. ', error);
session.output.write(error);
} else {
var prop = json.name;
var output = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:' + nxPrefix + '="http://www.w3.org/2001/XMLSchema">' +
'<soapenv:Header />' +
'<soapenv:Body>' +
'<' + nsPrefix + ':' + 'Document_OUT xmlns:ns0="urn:Document_OUT" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema">' +
'<' + nsPrefix + ':name>' + prop + '</' + nsPrefix + ':name>' +
'</' + nsPrefix + ':' + 'Document_OUT>' +
'</soapenv:Body>' +
'</soapenv:Envelope>';
hm.current.set('Content-Type', 'text/xml');
session.output.write(output);
}
})
} else {
statuscode = '1';
session.input.readAsJSON(function (error, json) {
if (error) {
console.error('Input is not valid JSON. ', error);
} else {
AnnotationID = 1;
statusdesc = json["Message"];
var output = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >' +
'<soapenv:Header />' +
'<soapenv:Body>' +
'<' + nsPrefix + ':' + 'Document_OUT xmlns:ns0="urn:mg_iBOLT_FileNet_Methods_CreateAnnotation_Document_OUT" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema">' +
'<' + nsPrefix + ':StatusCode>' + statuscode + '</' + nsPrefix + ':StatusCode>' + '<' + nsPrefix + ':StatusDesc>' + statusdesc + '</' + nsPrefix + ':StatusDesc>' +
'<' + nsPrefix + ':AnnotationID>' + AnnotationID + '</' + nsPrefix + ':AnnotationID>' +
'</' + nsPrefix + ':' + 'Document_OUT>' +
'</soapenv:Body>' +
//'</soapenv:Body>' +// Added
'</soapenv:Envelope>';
hm.current.set('Content-Type', 'text/xml');
session.output.write(output);
}
})
}