soap 0.45.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +7 -0
- package/Readme.md +12 -0
- package/lib/client.d.ts +1 -0
- package/lib/client.js +168 -187
- package/lib/client.js.map +1 -1
- package/lib/http.d.ts +1 -0
- package/lib/http.js +91 -101
- package/lib/http.js.map +1 -1
- package/lib/nscontext.js +38 -40
- package/lib/nscontext.js.map +1 -1
- package/lib/security/BasicAuthSecurity.js +11 -12
- package/lib/security/BasicAuthSecurity.js.map +1 -1
- package/lib/security/BearerSecurity.js +11 -12
- package/lib/security/BearerSecurity.js.map +1 -1
- package/lib/security/ClientSSLSecurity.js +12 -13
- package/lib/security/ClientSSLSecurity.js.map +1 -1
- package/lib/security/ClientSSLSecurityPFX.js +11 -12
- package/lib/security/ClientSSLSecurityPFX.js.map +1 -1
- package/lib/security/NTLMSecurity.js +12 -13
- package/lib/security/NTLMSecurity.js.map +1 -1
- package/lib/security/WSSecurity.js +21 -22
- package/lib/security/WSSecurity.js.map +1 -1
- package/lib/security/WSSecurityCert.d.ts +1 -0
- package/lib/security/WSSecurityCert.js +74 -56
- package/lib/security/WSSecurityCert.js.map +1 -1
- package/lib/security/WSSecurityPlusCert.d.ts +9 -0
- package/lib/security/WSSecurityPlusCert.js +17 -0
- package/lib/security/WSSecurityPlusCert.js.map +1 -0
- package/lib/security/index.d.ts +1 -0
- package/lib/security/index.js +8 -3
- package/lib/security/index.js.map +1 -1
- package/lib/server.d.ts +1 -0
- package/lib/server.js +189 -209
- package/lib/server.js.map +1 -1
- package/lib/soap.d.ts +1 -1
- package/lib/soap.js +45 -40
- package/lib/soap.js.map +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +55 -53
- package/lib/utils.js.map +1 -1
- package/lib/wsdl/elements.js +393 -515
- package/lib/wsdl/elements.js.map +1 -1
- package/lib/wsdl/index.js +322 -322
- package/lib/wsdl/index.js.map +1 -1
- package/package.json +8 -7
- package/tsconfig.json +2 -1
package/lib/wsdl/index.js
CHANGED
|
@@ -5,29 +5,29 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
/*jshint proto:true*/
|
|
8
|
-
exports
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.open_wsdl = exports.WSDL = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
const assert_1 = require("assert");
|
|
11
|
+
const debugBuilder = require("debug");
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const _ = require("lodash");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const sax = require("sax");
|
|
16
|
+
const stripBom = require("strip-bom");
|
|
17
|
+
const url = require("url");
|
|
18
|
+
const http_1 = require("../http");
|
|
19
|
+
const nscontext_1 = require("../nscontext");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
21
|
+
const elements = require("./elements");
|
|
22
|
+
const debug = debugBuilder('node-soap');
|
|
23
|
+
const XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
|
|
24
|
+
const trimLeft = /^[\s\xA0]+/;
|
|
25
|
+
const trimRight = /[\s\xA0]+$/;
|
|
26
26
|
function trim(text) {
|
|
27
27
|
return text.replace(trimLeft, '').replace(trimRight, '');
|
|
28
28
|
}
|
|
29
29
|
function deepMerge(destination, source) {
|
|
30
|
-
return _.mergeWith(destination, source,
|
|
30
|
+
return _.mergeWith(destination, source, (a, b) => {
|
|
31
31
|
return Array.isArray(a) ? a.concat(b) : undefined;
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -37,16 +37,15 @@ function appendColon(ns) {
|
|
|
37
37
|
function noColonNameSpace(ns) {
|
|
38
38
|
return (ns && ns.charAt(ns.length - 1) === ':') ? ns.substring(0, ns.length - 1) : ns;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _this = this;
|
|
40
|
+
class WSDL {
|
|
41
|
+
constructor(definition, uri, options) {
|
|
43
42
|
this.ignoredNamespaces = ['tns', 'targetNamespace', 'typedNamespace'];
|
|
44
43
|
this.ignoreBaseNameSpaces = false;
|
|
45
44
|
this.valueKey = '$value';
|
|
46
45
|
this.xmlKey = '$xml';
|
|
47
|
-
|
|
46
|
+
let fromFunc;
|
|
48
47
|
this.uri = uri;
|
|
49
|
-
this.callback =
|
|
48
|
+
this.callback = () => { };
|
|
50
49
|
this._includesWsdl = [];
|
|
51
50
|
// initialize WSDL cache
|
|
52
51
|
this.WSDL_CACHE = {};
|
|
@@ -64,48 +63,48 @@ var WSDL = /** @class */ (function () {
|
|
|
64
63
|
else {
|
|
65
64
|
throw new Error('WSDL constructor takes either an XML string or service definition');
|
|
66
65
|
}
|
|
67
|
-
process.nextTick(
|
|
66
|
+
process.nextTick(() => {
|
|
68
67
|
try {
|
|
69
|
-
fromFunc.call(
|
|
68
|
+
fromFunc.call(this, definition);
|
|
70
69
|
}
|
|
71
70
|
catch (e) {
|
|
72
|
-
return
|
|
71
|
+
return this.callback(e);
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
this.processIncludes((err) => {
|
|
74
|
+
let name;
|
|
76
75
|
if (err) {
|
|
77
|
-
return
|
|
76
|
+
return this.callback(err);
|
|
78
77
|
}
|
|
79
78
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
this.definitions.deleteFixedAttrs();
|
|
80
|
+
const services = this.services = this.definitions.services;
|
|
82
81
|
if (services) {
|
|
83
82
|
for (name in services) {
|
|
84
|
-
services[name].postProcess(
|
|
83
|
+
services[name].postProcess(this.definitions);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
const complexTypes = this.definitions.complexTypes;
|
|
88
87
|
if (complexTypes) {
|
|
89
88
|
for (name in complexTypes) {
|
|
90
89
|
complexTypes[name].deleteFixedAttrs();
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
// for document style, for every binding, prepare input message element name to (methodName, output message element name) mapping
|
|
94
|
-
|
|
95
|
-
for (
|
|
96
|
-
|
|
93
|
+
const bindings = this.definitions.bindings;
|
|
94
|
+
for (const bindingName in bindings) {
|
|
95
|
+
const binding = bindings[bindingName];
|
|
97
96
|
if (typeof binding.style === 'undefined') {
|
|
98
97
|
binding.style = 'document';
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
for (
|
|
99
|
+
const methods = binding.methods;
|
|
100
|
+
const topEls = binding.topElements = {};
|
|
101
|
+
for (const methodName in methods) {
|
|
103
102
|
if ((methods[methodName].style || binding.style) !== 'document') {
|
|
104
103
|
continue;
|
|
105
104
|
}
|
|
106
105
|
if (methods[methodName].input) {
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const inputName = methods[methodName].input.$name;
|
|
107
|
+
let outputName = '';
|
|
109
108
|
if (methods[methodName].output) {
|
|
110
109
|
outputName = methods[methodName].output.$name;
|
|
111
110
|
}
|
|
@@ -114,94 +113,93 @@ var WSDL = /** @class */ (function () {
|
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
// prepare soap envelope xmlns definition string
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
this.xmlnsInEnvelope = this._xmlnsMap();
|
|
117
|
+
this.callback(err, this);
|
|
119
118
|
}
|
|
120
119
|
catch (e) {
|
|
121
|
-
|
|
120
|
+
this.callback(e);
|
|
122
121
|
}
|
|
123
122
|
});
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
|
-
|
|
125
|
+
onReady(callback) {
|
|
127
126
|
if (callback) {
|
|
128
127
|
this.callback = callback;
|
|
129
128
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
|
|
129
|
+
}
|
|
130
|
+
processIncludes(callback) {
|
|
131
|
+
const schemas = this.definitions.schemas;
|
|
132
|
+
let includes = [];
|
|
133
|
+
for (const ns in schemas) {
|
|
134
|
+
const schema = schemas[ns];
|
|
136
135
|
includes = includes.concat(schema.includes || []);
|
|
137
136
|
}
|
|
138
137
|
this._processNextInclude(includes, callback);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
for (
|
|
143
|
-
|
|
144
|
-
services[
|
|
138
|
+
}
|
|
139
|
+
describeServices() {
|
|
140
|
+
const services = {};
|
|
141
|
+
for (const name in this.services) {
|
|
142
|
+
const service = this.services[name];
|
|
143
|
+
services[name] = service.description(this.definitions);
|
|
145
144
|
}
|
|
146
145
|
return services;
|
|
147
|
-
}
|
|
148
|
-
|
|
146
|
+
}
|
|
147
|
+
toXML() {
|
|
149
148
|
return this.xml || '';
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
}
|
|
150
|
+
getSaxStream(xml) {
|
|
151
|
+
const saxStream = sax.createStream(true, null);
|
|
153
152
|
xml.pipe(saxStream);
|
|
154
153
|
return saxStream;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var schema = {
|
|
154
|
+
}
|
|
155
|
+
xmlToObject(xml, callback) {
|
|
156
|
+
const p = typeof callback === 'function' ? {} : sax.parser(true, null);
|
|
157
|
+
let objectName = null;
|
|
158
|
+
const root = {};
|
|
159
|
+
const schema = {
|
|
162
160
|
Envelope: {
|
|
163
161
|
Header: {
|
|
164
162
|
Security: {
|
|
165
163
|
UsernameToken: {
|
|
166
164
|
Username: 'string',
|
|
167
|
-
Password: 'string'
|
|
168
|
-
}
|
|
169
|
-
}
|
|
165
|
+
Password: 'string',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
170
168
|
},
|
|
171
169
|
Body: {
|
|
172
170
|
Fault: {
|
|
173
171
|
faultcode: 'string',
|
|
174
172
|
faultstring: 'string',
|
|
175
|
-
detail: 'string'
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
173
|
+
detail: 'string',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
179
177
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
p.onopentag =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
const stack = [{ name: null, object: root, schema: schema }];
|
|
179
|
+
const xmlns = {};
|
|
180
|
+
const refs = {};
|
|
181
|
+
let id; // {id:{hrefs:[],obj:}, ...}
|
|
182
|
+
p.onopentag = (node) => {
|
|
183
|
+
const nsName = node.name;
|
|
184
|
+
const attrs = node.attributes;
|
|
185
|
+
let name = (0, utils_1.splitQName)(nsName).name;
|
|
186
|
+
let attributeName;
|
|
187
|
+
const top = stack[stack.length - 1];
|
|
188
|
+
let topSchema = top.schema;
|
|
189
|
+
const elementAttributes = {};
|
|
190
|
+
let hasNonXmlnsAttribute = false;
|
|
191
|
+
let hasNilAttribute = false;
|
|
192
|
+
const obj = {};
|
|
193
|
+
const originalName = name;
|
|
196
194
|
if (!objectName && top.name === 'Body' && name !== 'Fault') {
|
|
197
|
-
|
|
195
|
+
let message = this.definitions.messages[name];
|
|
198
196
|
// Support RPC/literal messages where response body contains one element named
|
|
199
197
|
// after the operation + 'Response'. See http://www.w3.org/TR/wsdl#_names
|
|
200
198
|
if (!message) {
|
|
201
199
|
try {
|
|
202
200
|
// Determine if this is request or response
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
let isInput = false;
|
|
202
|
+
let isOutput = false;
|
|
205
203
|
if ((/Response$/).test(name)) {
|
|
206
204
|
isOutput = true;
|
|
207
205
|
name = name.replace(/Response$/, '');
|
|
@@ -215,27 +213,27 @@ var WSDL = /** @class */ (function () {
|
|
|
215
213
|
name = name.replace(/Solicit$/, '');
|
|
216
214
|
}
|
|
217
215
|
// Look up the appropriate message as given in the portType's operations
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
const portTypes = this.definitions.portTypes;
|
|
217
|
+
const portTypeNames = Object.keys(portTypes);
|
|
220
218
|
// Currently this supports only one portType definition.
|
|
221
|
-
|
|
219
|
+
const portType = portTypes[portTypeNames[0]];
|
|
222
220
|
if (isInput) {
|
|
223
221
|
name = portType.methods[name].input.$name;
|
|
224
222
|
}
|
|
225
223
|
else {
|
|
226
224
|
name = portType.methods[name].output.$name;
|
|
227
225
|
}
|
|
228
|
-
message =
|
|
226
|
+
message = this.definitions.messages[name];
|
|
229
227
|
// 'cache' this alias to speed future lookups
|
|
230
|
-
|
|
228
|
+
this.definitions.messages[originalName] = this.definitions.messages[name];
|
|
231
229
|
}
|
|
232
230
|
catch (e) {
|
|
233
|
-
if (
|
|
231
|
+
if (this.options.returnFault) {
|
|
234
232
|
p.onerror(e);
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
}
|
|
238
|
-
topSchema = message.description(
|
|
236
|
+
topSchema = message.description(this.definitions);
|
|
239
237
|
objectName = originalName;
|
|
240
238
|
}
|
|
241
239
|
if (attrs.href) {
|
|
@@ -253,14 +251,14 @@ var WSDL = /** @class */ (function () {
|
|
|
253
251
|
// Handle element attributes
|
|
254
252
|
for (attributeName in attrs) {
|
|
255
253
|
if (/^xmlns:|^xmlns$/.test(attributeName)) {
|
|
256
|
-
xmlns[utils_1.splitQName(attributeName).name] = attrs[attributeName];
|
|
254
|
+
xmlns[(0, utils_1.splitQName)(attributeName).name] = attrs[attributeName];
|
|
257
255
|
continue;
|
|
258
256
|
}
|
|
259
257
|
hasNonXmlnsAttribute = true;
|
|
260
258
|
elementAttributes[attributeName] = attrs[attributeName];
|
|
261
259
|
}
|
|
262
260
|
for (attributeName in elementAttributes) {
|
|
263
|
-
|
|
261
|
+
const res = (0, utils_1.splitQName)(attributeName);
|
|
264
262
|
if (res.name === 'nil' && xmlns[res.prefix] === XSI_URI && elementAttributes[attributeName] &&
|
|
265
263
|
(elementAttributes[attributeName].toLowerCase() === 'true' || elementAttributes[attributeName] === '1')) {
|
|
266
264
|
hasNilAttribute = true;
|
|
@@ -268,20 +266,20 @@ var WSDL = /** @class */ (function () {
|
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
268
|
if (hasNonXmlnsAttribute) {
|
|
271
|
-
obj[
|
|
269
|
+
obj[this.options.attributesKey] = elementAttributes;
|
|
272
270
|
}
|
|
273
271
|
// Pick up the schema for the type specified in element's xsi:type attribute.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
for (
|
|
277
|
-
if (xmlns[prefix] === XSI_URI && (prefix
|
|
278
|
-
xsiType = elementAttributes[prefix
|
|
272
|
+
let xsiTypeSchema;
|
|
273
|
+
let xsiType;
|
|
274
|
+
for (const prefix in xmlns) {
|
|
275
|
+
if (xmlns[prefix] === XSI_URI && (`${prefix}:type` in elementAttributes)) {
|
|
276
|
+
xsiType = elementAttributes[`${prefix}:type`];
|
|
279
277
|
break;
|
|
280
278
|
}
|
|
281
279
|
}
|
|
282
280
|
if (xsiType) {
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
const type = (0, utils_1.splitQName)(xsiType);
|
|
282
|
+
let typeURI;
|
|
285
283
|
if (type.prefix === utils_1.TNS_PREFIX) {
|
|
286
284
|
// In case of xsi:type = "MyType"
|
|
287
285
|
typeURI = xmlns[type.prefix] || xmlns.xmlns;
|
|
@@ -289,9 +287,9 @@ var WSDL = /** @class */ (function () {
|
|
|
289
287
|
else {
|
|
290
288
|
typeURI = xmlns[type.prefix];
|
|
291
289
|
}
|
|
292
|
-
|
|
290
|
+
const typeDef = this.findSchemaObject(typeURI, type.name);
|
|
293
291
|
if (typeDef) {
|
|
294
|
-
xsiTypeSchema = typeDef.description(
|
|
292
|
+
xsiTypeSchema = typeDef.description(this.definitions);
|
|
295
293
|
}
|
|
296
294
|
}
|
|
297
295
|
if (topSchema && topSchema[name + '[]']) {
|
|
@@ -299,20 +297,20 @@ var WSDL = /** @class */ (function () {
|
|
|
299
297
|
}
|
|
300
298
|
stack.push({ name: originalName, object: obj, schema: (xsiTypeSchema || (topSchema && topSchema[name])), id: attrs.id, nil: hasNilAttribute });
|
|
301
299
|
};
|
|
302
|
-
p.onclosetag =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
300
|
+
p.onclosetag = (nsName) => {
|
|
301
|
+
const cur = stack.pop();
|
|
302
|
+
let obj = cur.object;
|
|
303
|
+
const top = stack[stack.length - 1];
|
|
304
|
+
const topObject = top.object;
|
|
305
|
+
const topSchema = top.schema;
|
|
306
|
+
const name = (0, utils_1.splitQName)(nsName).name;
|
|
309
307
|
if (typeof cur.schema === 'string' && (cur.schema === 'string' || cur.schema.split(':')[1] === 'string')) {
|
|
310
308
|
if (typeof obj === 'object' && Object.keys(obj).length === 0) {
|
|
311
309
|
obj = cur.object = '';
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
312
|
if (cur.nil === true) {
|
|
315
|
-
if (
|
|
313
|
+
if (this.options.handleNilAsNull) {
|
|
316
314
|
obj = null;
|
|
317
315
|
}
|
|
318
316
|
else {
|
|
@@ -341,48 +339,48 @@ var WSDL = /** @class */ (function () {
|
|
|
341
339
|
refs[cur.id].obj = obj;
|
|
342
340
|
}
|
|
343
341
|
};
|
|
344
|
-
p.oncdata =
|
|
345
|
-
|
|
342
|
+
p.oncdata = (text) => {
|
|
343
|
+
const originalText = text;
|
|
346
344
|
text = trim(text);
|
|
347
345
|
if (!text.length) {
|
|
348
346
|
return;
|
|
349
347
|
}
|
|
350
348
|
if (/<\?xml[\s\S]+\?>/.test(text)) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (
|
|
354
|
-
|
|
349
|
+
const top = stack[stack.length - 1];
|
|
350
|
+
const value = this.xmlToObject(text);
|
|
351
|
+
if (top.object[this.options.attributesKey]) {
|
|
352
|
+
top.object[this.options.valueKey] = value;
|
|
355
353
|
}
|
|
356
354
|
else {
|
|
357
|
-
|
|
355
|
+
top.object = value;
|
|
358
356
|
}
|
|
359
357
|
}
|
|
360
358
|
else {
|
|
361
359
|
p.ontext(originalText);
|
|
362
360
|
}
|
|
363
361
|
};
|
|
364
|
-
p.onerror =
|
|
362
|
+
p.onerror = (e) => {
|
|
365
363
|
p.resume();
|
|
366
364
|
throw {
|
|
367
365
|
Fault: {
|
|
368
366
|
faultcode: 500,
|
|
369
367
|
faultstring: 'Invalid XML',
|
|
370
368
|
detail: new Error(e).message,
|
|
371
|
-
statusCode: 500
|
|
372
|
-
}
|
|
369
|
+
statusCode: 500,
|
|
370
|
+
},
|
|
373
371
|
};
|
|
374
372
|
};
|
|
375
|
-
p.ontext =
|
|
376
|
-
|
|
373
|
+
p.ontext = (text) => {
|
|
374
|
+
const originalText = text;
|
|
377
375
|
text = trim(text);
|
|
378
376
|
if (!text.length) {
|
|
379
377
|
return;
|
|
380
378
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (
|
|
385
|
-
value =
|
|
379
|
+
const top = stack[stack.length - 1];
|
|
380
|
+
const name = (0, utils_1.splitQName)(top.schema).name;
|
|
381
|
+
let value;
|
|
382
|
+
if (this.options && this.options.customDeserializer && this.options.customDeserializer[name]) {
|
|
383
|
+
value = this.options.customDeserializer[name](text, top);
|
|
386
384
|
}
|
|
387
385
|
else {
|
|
388
386
|
if (name === 'int' || name === 'integer' || name === 'short' || name === 'long') {
|
|
@@ -398,7 +396,7 @@ var WSDL = /** @class */ (function () {
|
|
|
398
396
|
value = new Date(text);
|
|
399
397
|
}
|
|
400
398
|
else {
|
|
401
|
-
if (
|
|
399
|
+
if (this.options.preserveWhitespace) {
|
|
402
400
|
text = originalText;
|
|
403
401
|
}
|
|
404
402
|
// handle string or other types
|
|
@@ -410,8 +408,8 @@ var WSDL = /** @class */ (function () {
|
|
|
410
408
|
}
|
|
411
409
|
}
|
|
412
410
|
}
|
|
413
|
-
if (top.object[
|
|
414
|
-
top.object[
|
|
411
|
+
if (top.object[this.options.attributesKey]) {
|
|
412
|
+
top.object[this.options.valueKey] = value;
|
|
415
413
|
}
|
|
416
414
|
else {
|
|
417
415
|
top.object = value;
|
|
@@ -419,17 +417,17 @@ var WSDL = /** @class */ (function () {
|
|
|
419
417
|
};
|
|
420
418
|
if (typeof callback === 'function') {
|
|
421
419
|
// we be streaming
|
|
422
|
-
|
|
420
|
+
const saxStream = sax.createStream(true, null);
|
|
423
421
|
saxStream.on('opentag', p.onopentag);
|
|
424
422
|
saxStream.on('closetag', p.onclosetag);
|
|
425
423
|
saxStream.on('cdata', p.oncdata);
|
|
426
424
|
saxStream.on('text', p.ontext);
|
|
427
425
|
xml.pipe(saxStream)
|
|
428
|
-
.on('error',
|
|
426
|
+
.on('error', (err) => {
|
|
429
427
|
callback(err);
|
|
430
428
|
})
|
|
431
|
-
.on('end',
|
|
432
|
-
|
|
429
|
+
.on('end', () => {
|
|
430
|
+
let r;
|
|
433
431
|
try {
|
|
434
432
|
r = finish();
|
|
435
433
|
}
|
|
@@ -444,23 +442,22 @@ var WSDL = /** @class */ (function () {
|
|
|
444
442
|
return finish();
|
|
445
443
|
function finish() {
|
|
446
444
|
// MultiRef support: merge objects instead of replacing
|
|
447
|
-
for (
|
|
448
|
-
|
|
449
|
-
for (
|
|
450
|
-
var href = _a[_i];
|
|
445
|
+
for (const n in refs) {
|
|
446
|
+
const ref = refs[n];
|
|
447
|
+
for (const href of ref.hrefs) {
|
|
451
448
|
Object.assign(href.obj, ref.obj);
|
|
452
449
|
}
|
|
453
450
|
}
|
|
454
451
|
if (root.Envelope) {
|
|
455
|
-
|
|
452
|
+
const body = root.Envelope.Body;
|
|
456
453
|
if (body && body.Fault) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
let code = body.Fault.faultcode && body.Fault.faultcode.$value;
|
|
455
|
+
let string = body.Fault.faultstring && body.Fault.faultstring.$value;
|
|
456
|
+
let detail = body.Fault.detail && body.Fault.detail.$value;
|
|
460
457
|
code = code || body.Fault.faultcode;
|
|
461
458
|
string = string || body.Fault.faultstring;
|
|
462
459
|
detail = detail || body.Fault.detail;
|
|
463
|
-
|
|
460
|
+
const error = new Error(code + ': ' + string + (detail ? ': ' + JSON.stringify(detail) : ''));
|
|
464
461
|
error.root = root;
|
|
465
462
|
throw error;
|
|
466
463
|
}
|
|
@@ -468,20 +465,20 @@ var WSDL = /** @class */ (function () {
|
|
|
468
465
|
}
|
|
469
466
|
return root;
|
|
470
467
|
}
|
|
471
|
-
}
|
|
468
|
+
}
|
|
472
469
|
/**
|
|
473
470
|
* Look up a XSD type or element by namespace URI and name
|
|
474
471
|
* @param {String} nsURI Namespace URI
|
|
475
472
|
* @param {String} qname Local or qualified name
|
|
476
473
|
* @returns {*} The XSD type/element definition
|
|
477
474
|
*/
|
|
478
|
-
|
|
475
|
+
findSchemaObject(nsURI, qname) {
|
|
479
476
|
if (!nsURI || !qname) {
|
|
480
477
|
return null;
|
|
481
478
|
}
|
|
482
|
-
|
|
479
|
+
let def = null;
|
|
483
480
|
if (this.definitions.schemas) {
|
|
484
|
-
|
|
481
|
+
const schema = this.definitions.schemas[nsURI];
|
|
485
482
|
if (schema) {
|
|
486
483
|
if (qname.indexOf(':') !== -1) {
|
|
487
484
|
qname = qname.substring(qname.indexOf(':') + 1, qname.length);
|
|
@@ -492,7 +489,7 @@ var WSDL = /** @class */ (function () {
|
|
|
492
489
|
}
|
|
493
490
|
}
|
|
494
491
|
return def;
|
|
495
|
-
}
|
|
492
|
+
}
|
|
496
493
|
/**
|
|
497
494
|
* Create document style xml string from the parameters
|
|
498
495
|
* @param {String} name
|
|
@@ -501,16 +498,16 @@ var WSDL = /** @class */ (function () {
|
|
|
501
498
|
* @param {String} nsURI
|
|
502
499
|
* @param {String} type
|
|
503
500
|
*/
|
|
504
|
-
|
|
501
|
+
objectToDocumentXML(name, params, nsPrefix, nsURI, type) {
|
|
505
502
|
// If user supplies XML already, just use that. XML Declaration should not be present.
|
|
506
503
|
if (params && params._xml) {
|
|
507
504
|
return params._xml;
|
|
508
505
|
}
|
|
509
|
-
|
|
506
|
+
const args = {};
|
|
510
507
|
args[name] = params;
|
|
511
|
-
|
|
508
|
+
const parameterTypeObj = type ? this.findSchemaObject(nsURI, type) : null;
|
|
512
509
|
return this.objectToXML(args, null, nsPrefix, nsURI, true, null, parameterTypeObj);
|
|
513
|
-
}
|
|
510
|
+
}
|
|
514
511
|
/**
|
|
515
512
|
* Create RPC style xml string from the parameters
|
|
516
513
|
* @param {String} name
|
|
@@ -519,43 +516,43 @@ var WSDL = /** @class */ (function () {
|
|
|
519
516
|
* @param {String} nsURI
|
|
520
517
|
* @returns {string}
|
|
521
518
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
nsPrefix = nsPrefix || utils_1.findPrefix(defs.xmlns, nsURI);
|
|
519
|
+
objectToRpcXML(name, params, nsPrefix, nsURI, isParts) {
|
|
520
|
+
const parts = [];
|
|
521
|
+
const defs = this.definitions;
|
|
522
|
+
const nsAttrName = '_xmlns';
|
|
523
|
+
nsPrefix = nsPrefix || (0, utils_1.findPrefix)(defs.xmlns, nsURI);
|
|
527
524
|
nsURI = nsURI || defs.xmlns[nsPrefix];
|
|
528
525
|
nsPrefix = nsPrefix === utils_1.TNS_PREFIX ? '' : (nsPrefix + ':');
|
|
529
526
|
parts.push(['<', nsPrefix, name, '>'].join(''));
|
|
530
|
-
for (
|
|
527
|
+
for (const key in params) {
|
|
531
528
|
if (!params.hasOwnProperty(key)) {
|
|
532
529
|
continue;
|
|
533
530
|
}
|
|
534
531
|
if (key !== nsAttrName) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
532
|
+
const value = params[key];
|
|
533
|
+
const prefixedKey = (isParts ? '' : nsPrefix) + key;
|
|
534
|
+
const attributes = [];
|
|
538
535
|
if (typeof value === 'object' && value.hasOwnProperty(this.options.attributesKey)) {
|
|
539
|
-
|
|
540
|
-
for (
|
|
536
|
+
const attrs = value[this.options.attributesKey];
|
|
537
|
+
for (const n in attrs) {
|
|
541
538
|
attributes.push(' ' + n + '=' + '"' + attrs[n] + '"');
|
|
542
539
|
}
|
|
543
540
|
}
|
|
544
541
|
parts.push(['<', prefixedKey].concat(attributes).concat('>').join(''));
|
|
545
|
-
parts.push((typeof value === 'object') ? this.objectToXML(value, key, nsPrefix, nsURI) : utils_1.xmlEscape(value));
|
|
542
|
+
parts.push((typeof value === 'object') ? this.objectToXML(value, key, nsPrefix, nsURI) : (0, utils_1.xmlEscape)(value));
|
|
546
543
|
parts.push(['</', prefixedKey, '>'].join(''));
|
|
547
544
|
}
|
|
548
545
|
}
|
|
549
546
|
parts.push(['</', nsPrefix, name, '>'].join(''));
|
|
550
547
|
return parts.join('');
|
|
551
|
-
}
|
|
552
|
-
|
|
548
|
+
}
|
|
549
|
+
isIgnoredNameSpace(ns) {
|
|
553
550
|
return this.options.ignoredNamespaces.indexOf(ns) > -1;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
551
|
+
}
|
|
552
|
+
filterOutIgnoredNameSpace(ns) {
|
|
553
|
+
const namespace = noColonNameSpace(ns);
|
|
557
554
|
return this.isIgnoredNameSpace(namespace) ? '' : namespace;
|
|
558
|
-
}
|
|
555
|
+
}
|
|
559
556
|
/**
|
|
560
557
|
* Convert an object to XML. This is a recursive method as it calls itself.
|
|
561
558
|
*
|
|
@@ -569,9 +566,9 @@ var WSDL = /** @class */ (function () {
|
|
|
569
566
|
* @param {?} parameterTypeObject
|
|
570
567
|
* @param {NamespaceContext} nsContext Namespace context
|
|
571
568
|
*/
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
569
|
+
objectToXML(obj, name, nsPrefix, nsURI, isFirst, xmlnsAttr, schemaObject, nsContext) {
|
|
570
|
+
const schema = this.definitions.schemas[nsURI];
|
|
571
|
+
let parentNsPrefix = nsPrefix ? nsPrefix.parent : undefined;
|
|
575
572
|
if (typeof parentNsPrefix !== 'undefined') {
|
|
576
573
|
// we got the parentNsPrefix for our array. setting the namespace-variable back to the current namespace string
|
|
577
574
|
nsPrefix = nsPrefix.current;
|
|
@@ -580,14 +577,14 @@ var WSDL = /** @class */ (function () {
|
|
|
580
577
|
if (this.isIgnoredNameSpace(parentNsPrefix)) {
|
|
581
578
|
parentNsPrefix = '';
|
|
582
579
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
580
|
+
const soapHeader = !schema;
|
|
581
|
+
const qualified = schema && schema.$elementFormDefault === 'qualified';
|
|
582
|
+
const parts = [];
|
|
583
|
+
const prefixNamespace = (nsPrefix || qualified) && nsPrefix !== utils_1.TNS_PREFIX;
|
|
584
|
+
let xmlnsAttrib = '';
|
|
588
585
|
if (nsURI && isFirst) {
|
|
589
586
|
if (this.options.overrideRootElement && this.options.overrideRootElement.xmlnsAttributes) {
|
|
590
|
-
this.options.overrideRootElement.xmlnsAttributes.forEach(
|
|
587
|
+
this.options.overrideRootElement.xmlnsAttributes.forEach((attribute) => {
|
|
591
588
|
xmlnsAttrib += ' ' + attribute.name + '="' + attribute.value + '"';
|
|
592
589
|
});
|
|
593
590
|
}
|
|
@@ -613,20 +610,20 @@ var WSDL = /** @class */ (function () {
|
|
|
613
610
|
if (xmlnsAttr && !(this.options.overrideRootElement && this.options.overrideRootElement.xmlnsAttributes)) {
|
|
614
611
|
xmlnsAttrib = xmlnsAttr;
|
|
615
612
|
}
|
|
616
|
-
|
|
613
|
+
let ns = '';
|
|
617
614
|
if (this.options.overrideRootElement && isFirst) {
|
|
618
615
|
ns = this.options.overrideRootElement.namespace;
|
|
619
616
|
}
|
|
620
617
|
else if (prefixNamespace && (qualified || isFirst || soapHeader) && !this.isIgnoredNameSpace(nsPrefix)) {
|
|
621
618
|
ns = nsPrefix;
|
|
622
619
|
}
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
let i;
|
|
621
|
+
let n;
|
|
625
622
|
// start building out XML string.
|
|
626
623
|
if (Array.isArray(obj)) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
624
|
+
let nonSubNameSpace = '';
|
|
625
|
+
let emptyNonSubNameSpaceForArray = false;
|
|
626
|
+
const nameWithNsRegex = /^([^:]+):([^:]+)$/.exec(name);
|
|
630
627
|
if (nameWithNsRegex) {
|
|
631
628
|
nonSubNameSpace = nameWithNsRegex[1];
|
|
632
629
|
name = nameWithNsRegex[2];
|
|
@@ -636,11 +633,11 @@ var WSDL = /** @class */ (function () {
|
|
|
636
633
|
name = name.substr(1);
|
|
637
634
|
}
|
|
638
635
|
for (i = 0, n = obj.length; i < n; i++) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
636
|
+
const item = obj[i];
|
|
637
|
+
const arrayAttr = this.processAttributes(item, nsContext);
|
|
638
|
+
const correctOuterNsPrefix = nonSubNameSpace || parentNsPrefix || ns; // using the parent namespace prefix if given
|
|
639
|
+
const body = this.objectToXML(item, name, nsPrefix, nsURI, false, null, schemaObject, nsContext);
|
|
640
|
+
let openingTagParts = ['<', name, arrayAttr, xmlnsAttrib];
|
|
644
641
|
if (!emptyNonSubNameSpaceForArray) {
|
|
645
642
|
openingTagParts = ['<', appendColon(correctOuterNsPrefix), name, arrayAttr, xmlnsAttrib];
|
|
646
643
|
}
|
|
@@ -667,7 +664,7 @@ var WSDL = /** @class */ (function () {
|
|
|
667
664
|
}
|
|
668
665
|
}
|
|
669
666
|
else if (typeof obj === 'object') {
|
|
670
|
-
|
|
667
|
+
let currentChildXmlnsAttrib = '';
|
|
671
668
|
for (name in obj) {
|
|
672
669
|
// Happens when Object.create(null) is used, it will not inherit the Object prototype
|
|
673
670
|
if (!obj.hasOwnProperty) {
|
|
@@ -688,17 +685,17 @@ var WSDL = /** @class */ (function () {
|
|
|
688
685
|
// Its the value of an item. Return it directly.
|
|
689
686
|
if (name === this.options.valueKey) {
|
|
690
687
|
nsContext.popContext();
|
|
691
|
-
return utils_1.xmlEscape(obj[name]);
|
|
688
|
+
return (0, utils_1.xmlEscape)(obj[name]);
|
|
692
689
|
}
|
|
693
|
-
|
|
690
|
+
const child = obj[name];
|
|
694
691
|
if (typeof child === 'undefined') {
|
|
695
692
|
continue;
|
|
696
693
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
694
|
+
const attr = this.processAttributes(child, nsContext);
|
|
695
|
+
let value = '';
|
|
696
|
+
let nonSubNameSpace = '';
|
|
697
|
+
let emptyNonSubNameSpace = false;
|
|
698
|
+
const nameWithNsRegex = /^([^:]+):([^:]+)$/.exec(name);
|
|
702
699
|
if (nameWithNsRegex) {
|
|
703
700
|
nonSubNameSpace = nameWithNsRegex[1] + ':';
|
|
704
701
|
name = nameWithNsRegex[2];
|
|
@@ -713,7 +710,7 @@ var WSDL = /** @class */ (function () {
|
|
|
713
710
|
else {
|
|
714
711
|
if (this.definitions.schemas) {
|
|
715
712
|
if (schema) {
|
|
716
|
-
|
|
713
|
+
const childSchemaObject = this.findChildSchemaObject(schemaObject, name);
|
|
717
714
|
// find sub namespace if not a primitive
|
|
718
715
|
if (childSchemaObject &&
|
|
719
716
|
((childSchemaObject.$type && (childSchemaObject.$type.indexOf('xsd:') === -1)) ||
|
|
@@ -721,13 +718,13 @@ var WSDL = /** @class */ (function () {
|
|
|
721
718
|
/*if the base name space of the children is not in the ingoredSchemaNamspaces we use it.
|
|
722
719
|
This is because in some services the child nodes do not need the baseNameSpace.
|
|
723
720
|
*/
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
721
|
+
let childNsPrefix = '';
|
|
722
|
+
let childName = '';
|
|
723
|
+
let childNsURI;
|
|
724
|
+
let childXmlnsAttrib = '';
|
|
725
|
+
let elementQName = childSchemaObject.$ref || childSchemaObject.$name;
|
|
729
726
|
if (elementQName) {
|
|
730
|
-
elementQName = utils_1.splitQName(elementQName);
|
|
727
|
+
elementQName = (0, utils_1.splitQName)(elementQName);
|
|
731
728
|
childName = elementQName.name;
|
|
732
729
|
if (elementQName.prefix === utils_1.TNS_PREFIX) {
|
|
733
730
|
// Local element
|
|
@@ -744,7 +741,7 @@ var WSDL = /** @class */ (function () {
|
|
|
744
741
|
}
|
|
745
742
|
childNsURI = schema.xmlns[childNsPrefix] || this.definitions.xmlns[childNsPrefix];
|
|
746
743
|
}
|
|
747
|
-
|
|
744
|
+
let unqualified = false;
|
|
748
745
|
// Check qualification form for local elements
|
|
749
746
|
if (childSchemaObject.$name && childSchemaObject.targetNamespace === undefined) {
|
|
750
747
|
if (childSchemaObject.$form === 'unqualified') {
|
|
@@ -770,11 +767,11 @@ var WSDL = /** @class */ (function () {
|
|
|
770
767
|
}
|
|
771
768
|
}
|
|
772
769
|
}
|
|
773
|
-
|
|
770
|
+
let resolvedChildSchemaObject;
|
|
774
771
|
if (childSchemaObject.$type) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
772
|
+
const typeQName = (0, utils_1.splitQName)(childSchemaObject.$type);
|
|
773
|
+
const typePrefix = typeQName.prefix;
|
|
774
|
+
const typeURI = schema.xmlns[typePrefix] || this.definitions.xmlns[typePrefix];
|
|
778
775
|
childNsURI = typeURI;
|
|
779
776
|
if (typeURI !== 'http://www.w3.org/2001/XMLSchema' && typePrefix !== utils_1.TNS_PREFIX) {
|
|
780
777
|
// Add the prefix/namespace mapping, but not declare it
|
|
@@ -800,7 +797,7 @@ var WSDL = /** @class */ (function () {
|
|
|
800
797
|
// for arrays, we need to remember the current namespace
|
|
801
798
|
childNsPrefix = {
|
|
802
799
|
current: childNsPrefix,
|
|
803
|
-
parent: ns
|
|
800
|
+
parent: ns,
|
|
804
801
|
};
|
|
805
802
|
childXmlnsAttrib = childXmlnsAttrib && childXmlnsAttrib.length ? childXmlnsAttrib : currentChildXmlnsAttrib;
|
|
806
803
|
}
|
|
@@ -812,7 +809,7 @@ var WSDL = /** @class */ (function () {
|
|
|
812
809
|
}
|
|
813
810
|
else if (obj[this.options.attributesKey] && obj[this.options.attributesKey].xsi_type) {
|
|
814
811
|
// if parent object has complex type defined and child not found in parent
|
|
815
|
-
|
|
812
|
+
const completeChildParamTypeObject = this.findChildSchemaObject(obj[this.options.attributesKey].xsi_type.type, obj[this.options.attributesKey].xsi_type.xmlns);
|
|
816
813
|
nonSubNameSpace = obj[this.options.attributesKey].xsi_type.prefix;
|
|
817
814
|
nsContext.addNamespace(obj[this.options.attributesKey].xsi_type.prefix, obj[this.options.attributesKey].xsi_type.xmlns);
|
|
818
815
|
value = this.objectToXML(child, name, obj[this.options.attributesKey].xsi_type.prefix, obj[this.options.attributesKey].xsi_type.xmlns, false, null, null, nsContext);
|
|
@@ -841,7 +838,7 @@ var WSDL = /** @class */ (function () {
|
|
|
841
838
|
else if (this.isIgnoredNameSpace(ns)) {
|
|
842
839
|
ns = '';
|
|
843
840
|
}
|
|
844
|
-
|
|
841
|
+
const useEmptyTag = !value && this.options.useEmptyTag;
|
|
845
842
|
if (!Array.isArray(child)) {
|
|
846
843
|
// start tag
|
|
847
844
|
parts.push(['<', emptyNonSubNameSpace ? '' : appendColon(nonSubNameSpace || ns), name, attr, xmlnsAttrib,
|
|
@@ -859,20 +856,20 @@ var WSDL = /** @class */ (function () {
|
|
|
859
856
|
}
|
|
860
857
|
}
|
|
861
858
|
else if (obj !== undefined) {
|
|
862
|
-
parts.push((this.options.escapeXML) ? utils_1.xmlEscape(obj) : obj);
|
|
859
|
+
parts.push((this.options.escapeXML) ? (0, utils_1.xmlEscape)(obj) : obj);
|
|
863
860
|
}
|
|
864
861
|
nsContext.popContext();
|
|
865
862
|
return parts.join('');
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
|
|
863
|
+
}
|
|
864
|
+
processAttributes(child, nsContext) {
|
|
865
|
+
let attr = '';
|
|
869
866
|
if (child === null || child === undefined) {
|
|
870
867
|
child = [];
|
|
871
868
|
}
|
|
872
|
-
|
|
869
|
+
const attrObj = child[this.options.attributesKey] || {};
|
|
873
870
|
if (attrObj && attrObj.xsi_type) {
|
|
874
|
-
|
|
875
|
-
|
|
871
|
+
const xsiType = attrObj.xsi_type;
|
|
872
|
+
let prefix = xsiType.prefix || xsiType.namespace;
|
|
876
873
|
if (xsiType.xmlns) {
|
|
877
874
|
// Generate a new namespace for complex extension if one not provided
|
|
878
875
|
if (!prefix) {
|
|
@@ -884,41 +881,41 @@ var WSDL = /** @class */ (function () {
|
|
|
884
881
|
xsiType.prefix = prefix;
|
|
885
882
|
}
|
|
886
883
|
}
|
|
887
|
-
Object.keys(attrObj).forEach(
|
|
888
|
-
|
|
884
|
+
Object.keys(attrObj).forEach((k) => {
|
|
885
|
+
const v = attrObj[k];
|
|
889
886
|
if (k === 'xsi_type') {
|
|
890
|
-
|
|
887
|
+
let name = v.type;
|
|
891
888
|
if (v.prefix) {
|
|
892
|
-
|
|
889
|
+
name = `${v.prefix}:${name}`;
|
|
893
890
|
}
|
|
894
|
-
attr +=
|
|
891
|
+
attr += ` xsi:type="${name}"`;
|
|
895
892
|
if (v.xmlns) {
|
|
896
|
-
attr +=
|
|
893
|
+
attr += ` xmlns:${v.prefix}="${v.xmlns}"`;
|
|
897
894
|
}
|
|
898
895
|
}
|
|
899
896
|
else {
|
|
900
|
-
attr +=
|
|
897
|
+
attr += ` ${k}="${(0, utils_1.xmlEscape)(v)}"`;
|
|
901
898
|
}
|
|
902
899
|
});
|
|
903
900
|
return attr;
|
|
904
|
-
}
|
|
901
|
+
}
|
|
905
902
|
/**
|
|
906
903
|
* Look up a schema type definition
|
|
907
904
|
* @param name
|
|
908
905
|
* @param nsURI
|
|
909
906
|
* @returns {*}
|
|
910
907
|
*/
|
|
911
|
-
|
|
908
|
+
findSchemaType(name, nsURI) {
|
|
912
909
|
if (!this.definitions.schemas || !name || !nsURI) {
|
|
913
910
|
return null;
|
|
914
911
|
}
|
|
915
|
-
|
|
912
|
+
const schema = this.definitions.schemas[nsURI];
|
|
916
913
|
if (!schema || !schema.complexTypes) {
|
|
917
914
|
return null;
|
|
918
915
|
}
|
|
919
916
|
return schema.complexTypes[name];
|
|
920
|
-
}
|
|
921
|
-
|
|
917
|
+
}
|
|
918
|
+
findChildSchemaObject(parameterTypeObj, childName, backtrace) {
|
|
922
919
|
if (!parameterTypeObj || !childName) {
|
|
923
920
|
return null;
|
|
924
921
|
}
|
|
@@ -932,53 +929,53 @@ var WSDL = /** @class */ (function () {
|
|
|
932
929
|
else {
|
|
933
930
|
backtrace = backtrace.concat([parameterTypeObj]);
|
|
934
931
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
932
|
+
let found = null;
|
|
933
|
+
let i = 0;
|
|
934
|
+
let child;
|
|
935
|
+
let ref;
|
|
939
936
|
if (Array.isArray(parameterTypeObj.$lookupTypes) && parameterTypeObj.$lookupTypes.length) {
|
|
940
|
-
|
|
937
|
+
const types = parameterTypeObj.$lookupTypes;
|
|
941
938
|
for (i = 0; i < types.length; i++) {
|
|
942
|
-
|
|
939
|
+
const typeObj = types[i];
|
|
943
940
|
if (typeObj.$name === childName) {
|
|
944
941
|
found = typeObj;
|
|
945
942
|
break;
|
|
946
943
|
}
|
|
947
944
|
}
|
|
948
945
|
}
|
|
949
|
-
|
|
946
|
+
const object = parameterTypeObj;
|
|
950
947
|
if (object.$name === childName && object.name === 'element') {
|
|
951
948
|
return object;
|
|
952
949
|
}
|
|
953
950
|
if (object.$ref) {
|
|
954
|
-
ref = utils_1.splitQName(object.$ref);
|
|
951
|
+
ref = (0, utils_1.splitQName)(object.$ref);
|
|
955
952
|
if (ref.name === childName) {
|
|
956
953
|
return object;
|
|
957
954
|
}
|
|
958
955
|
}
|
|
959
|
-
|
|
956
|
+
let childNsURI;
|
|
960
957
|
// want to avoid unecessary recursion to improve performance
|
|
961
958
|
if (object.$type && backtrace.length === 1) {
|
|
962
|
-
|
|
959
|
+
const typeInfo = (0, utils_1.splitQName)(object.$type);
|
|
963
960
|
if (typeInfo.prefix === utils_1.TNS_PREFIX) {
|
|
964
961
|
childNsURI = parameterTypeObj.$targetNamespace;
|
|
965
962
|
}
|
|
966
963
|
else {
|
|
967
964
|
childNsURI = this.definitions.xmlns[typeInfo.prefix];
|
|
968
965
|
}
|
|
969
|
-
|
|
966
|
+
const typeDef = this.findSchemaType(typeInfo.name, childNsURI);
|
|
970
967
|
if (typeDef) {
|
|
971
968
|
return this.findChildSchemaObject(typeDef, childName, backtrace);
|
|
972
969
|
}
|
|
973
970
|
}
|
|
974
971
|
// handle $base (e.g. for ExtensionElement) like $type
|
|
975
972
|
if (object.$base && (!Array.isArray(object.children) || !object.children.length)) {
|
|
976
|
-
|
|
973
|
+
const baseInfo = (0, utils_1.splitQName)(object.$base);
|
|
977
974
|
childNsURI = parameterTypeObj.$targetNamespace;
|
|
978
975
|
if (baseInfo.prefix !== utils_1.TNS_PREFIX) {
|
|
979
976
|
childNsURI = this.definitions.xmlns[baseInfo.prefix];
|
|
980
977
|
}
|
|
981
|
-
|
|
978
|
+
const baseDef = this.findSchemaType(baseInfo.name, childNsURI);
|
|
982
979
|
if (baseDef) {
|
|
983
980
|
return this.findChildSchemaObject(baseDef, childName, backtrace);
|
|
984
981
|
}
|
|
@@ -990,10 +987,10 @@ var WSDL = /** @class */ (function () {
|
|
|
990
987
|
break;
|
|
991
988
|
}
|
|
992
989
|
if (child.$base) {
|
|
993
|
-
|
|
994
|
-
|
|
990
|
+
const baseQName = (0, utils_1.splitQName)(child.$base);
|
|
991
|
+
const childNameSpace = baseQName.prefix === utils_1.TNS_PREFIX ? '' : baseQName.prefix;
|
|
995
992
|
childNsURI = child.xmlns[baseQName.prefix] || child.schemaXmlns[baseQName.prefix];
|
|
996
|
-
|
|
993
|
+
const foundBase = this.findSchemaType(baseQName.name, childNsURI);
|
|
997
994
|
if (foundBase) {
|
|
998
995
|
found = this.findChildSchemaObject(foundBase, childName, backtrace);
|
|
999
996
|
if (found) {
|
|
@@ -1009,11 +1006,11 @@ var WSDL = /** @class */ (function () {
|
|
|
1009
1006
|
return object;
|
|
1010
1007
|
}
|
|
1011
1008
|
return found;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1009
|
+
}
|
|
1010
|
+
_initializeOptions(options) {
|
|
1014
1011
|
this._originalIgnoredNamespaces = (options || {}).ignoredNamespaces;
|
|
1015
1012
|
this.options = {};
|
|
1016
|
-
|
|
1013
|
+
const ignoredNamespaces = options ? options.ignoredNamespaces : null;
|
|
1017
1014
|
if (ignoredNamespaces &&
|
|
1018
1015
|
(Array.isArray(ignoredNamespaces.namespaces) || typeof ignoredNamespaces.namespaces === 'string')) {
|
|
1019
1016
|
if (ignoredNamespaces.override) {
|
|
@@ -1057,7 +1054,7 @@ var WSDL = /** @class */ (function () {
|
|
|
1057
1054
|
if (options.request) {
|
|
1058
1055
|
this.options.request = options.request;
|
|
1059
1056
|
}
|
|
1060
|
-
|
|
1057
|
+
const ignoreBaseNameSpaces = options ? options.ignoreBaseNameSpaces : null;
|
|
1061
1058
|
if (ignoreBaseNameSpaces !== null && typeof ignoreBaseNameSpaces !== 'undefined') {
|
|
1062
1059
|
this.options.ignoreBaseNameSpaces = ignoreBaseNameSpaces;
|
|
1063
1060
|
}
|
|
@@ -1071,16 +1068,15 @@ var WSDL = /** @class */ (function () {
|
|
|
1071
1068
|
this.options.overrideRootElement = options.overrideRootElement;
|
|
1072
1069
|
}
|
|
1073
1070
|
this.options.useEmptyTag = !!options.useEmptyTag;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
var include = includes.shift();
|
|
1071
|
+
}
|
|
1072
|
+
_processNextInclude(includes, callback) {
|
|
1073
|
+
const include = includes.shift();
|
|
1078
1074
|
if (!include) {
|
|
1079
1075
|
return callback();
|
|
1080
1076
|
}
|
|
1081
|
-
|
|
1077
|
+
let includePath;
|
|
1082
1078
|
if (!/^https?:/i.test(this.uri) && !/^https?:/i.test(include.location)) {
|
|
1083
|
-
|
|
1079
|
+
const isFixed = (this.options.wsdl_options !== undefined && this.options.wsdl_options.hasOwnProperty('fixedPath')) ? this.options.wsdl_options.fixedPath : false;
|
|
1084
1080
|
if (isFixed) {
|
|
1085
1081
|
includePath = path.resolve(path.dirname(this.uri), path.parse(include.location).base);
|
|
1086
1082
|
}
|
|
@@ -1094,42 +1090,41 @@ var WSDL = /** @class */ (function () {
|
|
|
1094
1090
|
if (this.options.wsdl_options !== undefined && typeof this.options.wsdl_options.overrideImportLocation === 'function') {
|
|
1095
1091
|
includePath = this.options.wsdl_options.overrideImportLocation(includePath);
|
|
1096
1092
|
}
|
|
1097
|
-
|
|
1093
|
+
const options = Object.assign({}, this.options);
|
|
1098
1094
|
// follow supplied ignoredNamespaces option
|
|
1099
1095
|
options.ignoredNamespaces = this._originalIgnoredNamespaces || this.options.ignoredNamespaces;
|
|
1100
1096
|
options.WSDL_CACHE = this.WSDL_CACHE;
|
|
1101
|
-
open_wsdl_recursive(includePath, options,
|
|
1097
|
+
open_wsdl_recursive(includePath, options, (err, wsdl) => {
|
|
1102
1098
|
if (err) {
|
|
1103
1099
|
return callback(err);
|
|
1104
1100
|
}
|
|
1105
|
-
|
|
1101
|
+
this._includesWsdl.push(wsdl);
|
|
1106
1102
|
if (wsdl.definitions instanceof elements.DefinitionsElement) {
|
|
1107
|
-
_.mergeWith(
|
|
1103
|
+
_.mergeWith(this.definitions, wsdl.definitions, (a, b) => {
|
|
1108
1104
|
return (a instanceof elements.SchemaElement) ? a.merge(b) : undefined;
|
|
1109
1105
|
});
|
|
1110
1106
|
}
|
|
1111
1107
|
else {
|
|
1112
1108
|
return callback(new Error('wsdl.defintions is not an instance of elements.DefinitionsElement'));
|
|
1113
1109
|
}
|
|
1114
|
-
|
|
1110
|
+
this._processNextInclude(includes, (err) => {
|
|
1115
1111
|
callback(err);
|
|
1116
1112
|
});
|
|
1117
1113
|
});
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
var name = utils_1.splitQName(nsName).name;
|
|
1114
|
+
}
|
|
1115
|
+
_parse(xml) {
|
|
1116
|
+
const p = sax.parser(true, null);
|
|
1117
|
+
const stack = [];
|
|
1118
|
+
let root = null;
|
|
1119
|
+
let types = null;
|
|
1120
|
+
let schema = null;
|
|
1121
|
+
let schemaAttrs = null;
|
|
1122
|
+
const options = this.options;
|
|
1123
|
+
p.onopentag = (node) => {
|
|
1124
|
+
const nsName = node.name;
|
|
1125
|
+
const attrs = node.attributes;
|
|
1126
|
+
const top = stack[stack.length - 1];
|
|
1127
|
+
const name = (0, utils_1.splitQName)(nsName).name;
|
|
1133
1128
|
if (name === 'schema') {
|
|
1134
1129
|
schemaAttrs = attrs;
|
|
1135
1130
|
}
|
|
@@ -1138,7 +1133,7 @@ var WSDL = /** @class */ (function () {
|
|
|
1138
1133
|
top.startElement(stack, nsName, attrs, options, schemaAttrs);
|
|
1139
1134
|
}
|
|
1140
1135
|
catch (e) {
|
|
1141
|
-
if (
|
|
1136
|
+
if (this.options.strict) {
|
|
1142
1137
|
throw e;
|
|
1143
1138
|
}
|
|
1144
1139
|
else {
|
|
@@ -1165,32 +1160,32 @@ var WSDL = /** @class */ (function () {
|
|
|
1165
1160
|
}
|
|
1166
1161
|
}
|
|
1167
1162
|
};
|
|
1168
|
-
p.onclosetag =
|
|
1169
|
-
|
|
1170
|
-
assert_1.ok(top, 'Unmatched close tag: ' + name);
|
|
1163
|
+
p.onclosetag = (name) => {
|
|
1164
|
+
const top = stack[stack.length - 1];
|
|
1165
|
+
(0, assert_1.ok)(top, 'Unmatched close tag: ' + name);
|
|
1171
1166
|
top.endElement(stack, name);
|
|
1172
1167
|
};
|
|
1173
1168
|
p.write(xml).close();
|
|
1174
1169
|
return root;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1170
|
+
}
|
|
1171
|
+
_fromXML(xml) {
|
|
1177
1172
|
this.definitions = this._parse(xml);
|
|
1178
1173
|
this.definitions.descriptions = {
|
|
1179
1174
|
types: {},
|
|
1180
|
-
elements: {}
|
|
1175
|
+
elements: {},
|
|
1181
1176
|
};
|
|
1182
1177
|
this.xml = xml;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
for (
|
|
1178
|
+
}
|
|
1179
|
+
_fromServices(services) {
|
|
1180
|
+
}
|
|
1181
|
+
_xmlnsMap() {
|
|
1182
|
+
const xmlns = this.definitions.xmlns;
|
|
1183
|
+
let str = '';
|
|
1184
|
+
for (const alias in xmlns) {
|
|
1190
1185
|
if (alias === '' || alias === utils_1.TNS_PREFIX) {
|
|
1191
1186
|
continue;
|
|
1192
1187
|
}
|
|
1193
|
-
|
|
1188
|
+
const ns = xmlns[alias];
|
|
1194
1189
|
switch (ns) {
|
|
1195
1190
|
case 'http://xml.apache.org/xml-soap': // apachesoap
|
|
1196
1191
|
case 'http://schemas.xmlsoap.org/wsdl/': // wsdl
|
|
@@ -1212,15 +1207,14 @@ var WSDL = /** @class */ (function () {
|
|
|
1212
1207
|
str += ' xmlns:' + alias + '="' + ns + '"';
|
|
1213
1208
|
}
|
|
1214
1209
|
return str;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
}());
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1218
1212
|
exports.WSDL = WSDL;
|
|
1219
1213
|
function open_wsdl_recursive(uri, p2, p3) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1214
|
+
let fromCache;
|
|
1215
|
+
let WSDL_CACHE;
|
|
1216
|
+
let options;
|
|
1217
|
+
let callback;
|
|
1224
1218
|
if (typeof p2 === 'function') {
|
|
1225
1219
|
options = {};
|
|
1226
1220
|
callback = p2;
|
|
@@ -1236,8 +1230,8 @@ function open_wsdl_recursive(uri, p2, p3) {
|
|
|
1236
1230
|
return open_wsdl(uri, options, callback);
|
|
1237
1231
|
}
|
|
1238
1232
|
function open_wsdl(uri, p2, p3) {
|
|
1239
|
-
|
|
1240
|
-
|
|
1233
|
+
let options;
|
|
1234
|
+
let callback;
|
|
1241
1235
|
if (typeof p2 === 'function') {
|
|
1242
1236
|
options = {};
|
|
1243
1237
|
callback = p2;
|
|
@@ -1247,13 +1241,19 @@ function open_wsdl(uri, p2, p3) {
|
|
|
1247
1241
|
callback = p3;
|
|
1248
1242
|
}
|
|
1249
1243
|
// initialize cache when calling open_wsdl directly
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
if (
|
|
1244
|
+
const WSDL_CACHE = options.WSDL_CACHE || {};
|
|
1245
|
+
const request_headers = options.wsdl_headers;
|
|
1246
|
+
const request_options = options.wsdl_options;
|
|
1247
|
+
let wsdl;
|
|
1248
|
+
if (/^\<\?xml[^>]*?>/i.test(uri)) {
|
|
1249
|
+
wsdl = new WSDL(uri, uri, options);
|
|
1250
|
+
WSDL_CACHE[uri] = wsdl;
|
|
1251
|
+
wsdl.WSDL_CACHE = WSDL_CACHE;
|
|
1252
|
+
wsdl.onReady(callback);
|
|
1253
|
+
}
|
|
1254
|
+
else if (!/^https?:/i.test(uri)) {
|
|
1255
1255
|
debug('Reading file: %s', uri);
|
|
1256
|
-
fs.readFile(uri, 'utf8',
|
|
1256
|
+
fs.readFile(uri, 'utf8', (err, definition) => {
|
|
1257
1257
|
if (err) {
|
|
1258
1258
|
callback(err);
|
|
1259
1259
|
}
|
|
@@ -1267,8 +1267,8 @@ function open_wsdl(uri, p2, p3) {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
else {
|
|
1269
1269
|
debug('Reading url: %s', uri);
|
|
1270
|
-
|
|
1271
|
-
httpClient.request(uri, null /* options */,
|
|
1270
|
+
const httpClient = options.httpClient || new http_1.HttpClient(options);
|
|
1271
|
+
httpClient.request(uri, null /* options */, (err, response, definition) => {
|
|
1272
1272
|
if (err) {
|
|
1273
1273
|
callback(err);
|
|
1274
1274
|
}
|