xml-toolkit 1.0.26 → 1.0.28
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 +26 -0
- package/lib/SOAP11.js +4 -1
- package/lib/SOAP12.js +5 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -107,4 +107,30 @@ const rq = http.request (endpointURL, {method, headers})
|
|
|
107
107
|
rq.write (body)
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
* [Implementing](https://github.com/do-/node-xml-toolkit/wiki/Use-Case:-Implement-a-SOAP-Web-Service) a SOAP service
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
const {XMLSchemata, SOAP11, SOAP12, SOAPFault} = require ('xml-toolkit')
|
|
114
|
+
|
|
115
|
+
const SOAP = SOAP11 // or SOAP12
|
|
116
|
+
|
|
117
|
+
const xs = new XMLSchemata (`myService.wsdl`)
|
|
118
|
+
|
|
119
|
+
let body, statusCode; try {
|
|
120
|
+
body = xs.stringify (myMethod (/*...*/))
|
|
121
|
+
statusCode = 200
|
|
122
|
+
}
|
|
123
|
+
catch (x) {
|
|
124
|
+
body = new SOAPFault (x)
|
|
125
|
+
statusCode = 500
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
rp.writeHead (statusCode, {
|
|
129
|
+
'Content-Type': SOAP.contentType,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const xml = SOAP.message (body)
|
|
133
|
+
rp.end (xml)
|
|
134
|
+
```
|
|
135
|
+
|
|
110
136
|
For more information, see [wiki docs](https://github.com/do-/node-xml-toolkit/wiki).
|
package/lib/SOAP11.js
CHANGED
|
@@ -8,6 +8,8 @@ const SOAPFault = require ('./SOAPFault.js')
|
|
|
8
8
|
|
|
9
9
|
const WSDL = {namespaceURI: 'http://schemas.xmlsoap.org/wsdl/'}
|
|
10
10
|
|
|
11
|
+
const _contentType = 'text/xml'
|
|
12
|
+
|
|
11
13
|
let _xs = null
|
|
12
14
|
|
|
13
15
|
const get_xs = () => {
|
|
@@ -127,7 +129,7 @@ const SOAP11 = class {
|
|
|
127
129
|
|
|
128
130
|
const encoding = 'UTF-8'
|
|
129
131
|
|
|
130
|
-
let headers = {'Content-Type': '
|
|
132
|
+
let headers = {'Content-Type': _contentType + '; charset=' + encoding.toLowerCase ()}
|
|
131
133
|
|
|
132
134
|
for (const elementLocalName in body [0]) {
|
|
133
135
|
|
|
@@ -150,6 +152,7 @@ const SOAP11 = class {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
SOAP11.namespaceURI = 'http://schemas.xmlsoap.org/wsdl/soap/'
|
|
155
|
+
SOAP11.contentType = _contentType
|
|
153
156
|
|
|
154
157
|
SOAP11.fromFile = async function (fn, options = {}) {
|
|
155
158
|
|
package/lib/SOAP12.js
CHANGED
|
@@ -4,6 +4,8 @@ const SOAPFault = require ('./SOAPFault.js')
|
|
|
4
4
|
|
|
5
5
|
let _xs = null
|
|
6
6
|
|
|
7
|
+
const _contentType = 'application/soap+xml'
|
|
8
|
+
|
|
7
9
|
const get_xs = () => {
|
|
8
10
|
|
|
9
11
|
if (_xs === null) _xs = new XMLSchemata (path.join (path.dirname (module.filename), 'soap-1.2.xsd'))
|
|
@@ -61,7 +63,7 @@ const SOAP12 = class {
|
|
|
61
63
|
|
|
62
64
|
return {
|
|
63
65
|
method: 'POST',
|
|
64
|
-
headers: {'Content-Type': '
|
|
66
|
+
headers: {'Content-Type': _contentType +'; charset=' + encoding.toLowerCase ()},
|
|
65
67
|
body: _message (body, header, {declaration: {encoding}})
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -69,6 +71,8 @@ const SOAP12 = class {
|
|
|
69
71
|
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
SOAP12.contentType = _contentType
|
|
75
|
+
|
|
72
76
|
SOAP12.message = _message
|
|
73
77
|
|
|
74
78
|
module.exports = SOAP12
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xml-toolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "Collection of classes for dealing with XML",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"xml",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"soap",
|
|
16
|
+
"xsd",
|
|
17
|
+
"sax"
|
|
17
18
|
],
|
|
18
19
|
"author": "Dmitry Ovsyanko",
|
|
19
20
|
"license": "MIT",
|