xml-toolkit 1.0.18 → 1.0.19
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/README.md +1 -1
- package/lib/SOAP11.js +25 -5
- package/lib/XMLSchemata.js +8 -2
- package/package.json +1 -1
- package/test/test.js +8 -4
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ const xml = xs.stringify (data)
|
|
|
99
99
|
const http = require ('http')
|
|
100
100
|
const {SOAP11} = require ('xml-toolkit')
|
|
101
101
|
|
|
102
|
-
const soap =
|
|
102
|
+
const soap = new SOAP11 ('their.wsdl')
|
|
103
103
|
|
|
104
104
|
const {method, headers, body} = soap.http ({RequestElementNameOfTheirs: {amount: '0.01'}})
|
|
105
105
|
|
package/lib/SOAP11.js
CHANGED
|
@@ -7,9 +7,27 @@ const SOAPHTTP = require ('./SOAPHTTP.js')
|
|
|
7
7
|
|
|
8
8
|
const SOAP11 = class {
|
|
9
9
|
|
|
10
|
+
constructor (fn) {
|
|
11
|
+
|
|
12
|
+
this.definitions = []
|
|
13
|
+
|
|
14
|
+
if (fn) {
|
|
15
|
+
|
|
16
|
+
this.xs = new XMLSchemata (fn)
|
|
17
|
+
|
|
18
|
+
for (const doc of this.xs.documents)
|
|
19
|
+
|
|
20
|
+
if (doc.localName === 'definitions' && doc.namespaceURI === 'http://schemas.xmlsoap.org/wsdl/')
|
|
21
|
+
|
|
22
|
+
this.definitions.push (doc)
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
getMessageLocalNameByElementLocalName (elementLocalName) {
|
|
11
29
|
|
|
12
|
-
for (const
|
|
30
|
+
for (const d of this.definitions) for (const m of d.children) if (m.localName === 'message')
|
|
13
31
|
|
|
14
32
|
for (const p of m.children) if (p.localName === 'part')
|
|
15
33
|
|
|
@@ -21,7 +39,7 @@ const SOAP11 = class {
|
|
|
21
39
|
|
|
22
40
|
getOperationNameByMessageLocalName (messageLocalName) {
|
|
23
41
|
|
|
24
|
-
for (const
|
|
42
|
+
for (const d of this.definitions) for (const p of d.children) if (p.localName === 'portType')
|
|
25
43
|
|
|
26
44
|
for (const o of p.children) if (o.localName === 'operation')
|
|
27
45
|
|
|
@@ -36,7 +54,7 @@ const SOAP11 = class {
|
|
|
36
54
|
|
|
37
55
|
getSoapActionByOperationName (operationName) {
|
|
38
56
|
|
|
39
|
-
for (const
|
|
57
|
+
for (const d of this.definitions) for (const b of d.children) if (b.localName === 'binding')
|
|
40
58
|
|
|
41
59
|
for (const o of b.children) if (o.localName === 'operation' && o.attributes.get ('name') === operationName)
|
|
42
60
|
|
|
@@ -97,11 +115,13 @@ SOAP11.fromFile = async function (fn, options = {}) {
|
|
|
97
115
|
|
|
98
116
|
s.xs = await XMLSchemata.fromFile (fn)
|
|
99
117
|
|
|
100
|
-
|
|
118
|
+
const nodes = new XMLReader ({
|
|
101
119
|
filterElements: e =>
|
|
102
120
|
e.namespaceURI === WSDL.namespaceURI &&
|
|
103
121
|
e.localName === 'definitions'
|
|
104
|
-
}).process (fs.createReadStream (fn))
|
|
122
|
+
}).process (fs.createReadStream (fn))
|
|
123
|
+
|
|
124
|
+
for await (const node of nodes) s.definitions.push (node)
|
|
105
125
|
|
|
106
126
|
return s
|
|
107
127
|
|
package/lib/XMLSchemata.js
CHANGED
|
@@ -20,6 +20,8 @@ const XMLSchemata = class extends Map {
|
|
|
20
20
|
|
|
21
21
|
this [IDX] = new Map ()
|
|
22
22
|
|
|
23
|
+
this.documents = []
|
|
24
|
+
|
|
23
25
|
if (fn) {
|
|
24
26
|
this.parser = new XMLParser ()
|
|
25
27
|
this.addFileSync (fn)
|
|
@@ -166,10 +168,14 @@ const XMLSchemata = class extends Map {
|
|
|
166
168
|
options.addLocation = function (schemaLocation, namespace) {
|
|
167
169
|
|
|
168
170
|
that.addFileSync (path.join (dirname, schemaLocation), {targetNamespace: namespace})
|
|
169
|
-
|
|
171
|
+
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
|
|
174
|
+
const document = this.parser.process (fs.readFileSync (fn, 'utf-8'))
|
|
175
|
+
|
|
176
|
+
this.documents.push (document)
|
|
177
|
+
|
|
178
|
+
this.addSchemaSync (document, options)
|
|
173
179
|
|
|
174
180
|
}
|
|
175
181
|
|
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -335,10 +335,14 @@ async function test_006_schemata (fn) {
|
|
|
335
335
|
async function test_007_wsdl (fn) {
|
|
336
336
|
|
|
337
337
|
const soap = await SOAP11.fromFile ('test/20186.wsdl')
|
|
338
|
+
const soaps = new SOAP11 ('test/20186.wsdl')
|
|
339
|
+
|
|
340
|
+
const d = {GetForm9Sync: {address: {Region: {Code: 78}}}}
|
|
338
341
|
|
|
339
|
-
console.log (soap.http (
|
|
342
|
+
console.log (soap.http (d))
|
|
343
|
+
console.log (soaps.http (d))
|
|
340
344
|
|
|
341
|
-
console.log (soap)
|
|
345
|
+
// console.log (soap)
|
|
342
346
|
|
|
343
347
|
}
|
|
344
348
|
|
|
@@ -453,10 +457,10 @@ async function main () {
|
|
|
453
457
|
// await test_003_emitter_sync ('not-sa01.xml')
|
|
454
458
|
// await test_003_emitter_sync ('ent.xml')
|
|
455
459
|
// await test_003_emitter_sync ('soap.xml')
|
|
456
|
-
await test_004_schemata ()
|
|
460
|
+
// await test_004_schemata ()
|
|
457
461
|
// await test_005_schemata ()
|
|
458
462
|
// await test_006_schemata ()
|
|
459
|
-
|
|
463
|
+
await test_007_wsdl ()
|
|
460
464
|
// await test_008_schemata ()
|
|
461
465
|
|
|
462
466
|
// test_010_node ()
|