soap 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/Readme.md +653 -505
  2. package/package.json +2 -2
package/Readme.md CHANGED
@@ -1,8 +1,10 @@
1
- # Soap [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Coveralls Status][coveralls-image]][coveralls-url]
1
+ [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Coveralls Status][coveralls-image]][coveralls-url]
2
2
 
3
- > A SOAP client and server for node.js.
3
+ [![Support][buy-me-a-coffee-image]][buy-me-a-coffee-url]
4
4
 
5
- This module lets you connect to web services using SOAP. It also provides a server that allows you to run your own SOAP services.
5
+ # SOAP client and server for node.js.
6
+
7
+ This module lets you connect to web services using SOAP. It also provides a server that allows you to run your own SOAP services.
6
8
 
7
9
  <!-- Run `npm run toc` to update below section -->
8
10
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
@@ -14,8 +16,8 @@ This module lets you connect to web services using SOAP. It also provides a ser
14
16
  - [Module](#module)
15
17
  - [soap.createClient(url[, options], callback) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.](#soapcreateclienturl-options-callback---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path)
16
18
  - [soap.createClientAsync(url[, options]) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.](#soapcreateclientasyncurl-options---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path)
17
- - [soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.](#soaplistenserver-path-services-wsdl-callback---create-a-new-soap-server-that-listens-on-path-and-provides-services)
18
- - [soap.listen(*server*, *options*) - create a new SOAP server that listens on *path* and provides *services*.](#soaplistenserver-options---create-a-new-soap-server-that-listens-on-path-and-provides-services)
19
+ - [soap.listen(_server_, _path_, _services_, _wsdl_, _callback_) - create a new SOAP server that listens on _path_ and provides _services_.](#soaplistenserver-path-services-wsdl-callback---create-a-new-soap-server-that-listens-on-path-and-provides-services)
20
+ - [soap.listen(_server_, _options_) - create a new SOAP server that listens on _path_ and provides _services_.](#soaplistenserver-options---create-a-new-soap-server-that-listens-on-path-and-provides-services)
19
21
  - [Server Logging](#server-logging)
20
22
  - [Server Events](#server-events)
21
23
  - [Server Response on one-way calls](#server-response-on-one-way-calls)
@@ -28,11 +30,11 @@ This module lets you connect to web services using SOAP. It also provides a ser
28
30
  - [Client](#client)
29
31
  - [Client.describe() - description of services, ports and methods as a JavaScript object](#clientdescribe---description-of-services-ports-and-methods-as-a-javascript-object)
30
32
  - [Client.setSecurity(security) - use the specified security protocol](#clientsetsecuritysecurity---use-the-specified-security-protocol)
31
- - [Client.*method*(args, callback, options) - call *method* on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service)
32
- - [Client.*method*Async(args, options) - call *method* on the SOAP service.](#clientmethodasyncargs-options---call-method-on-the-soap-service)
33
- - [Client.*service*.*port*.*method*(args, callback[, options[, extraHeaders]]) - call a *method* using a specific *service* and *port*](#clientserviceportmethodargs-callback-options-extraheaders---call-a-method-using-a-specific-service-and-port)
33
+ - [Client._method_(args, callback, options) - call _method_ on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service)
34
+ - [Client.*method*Async(args, options) - call _method_ on the SOAP service.](#clientmethodasyncargs-options---call-method-on-the-soap-service)
35
+ - [Client._service_._port_._method_(args, callback[, options[, extraHeaders]]) - call a _method_ using a specific _service_ and _port_](#clientserviceportmethodargs-callback-options-extraheaders---call-a-method-using-a-specific-service-and-port)
34
36
  - [Overriding the namespace prefix](#overriding-the-namespace-prefix)
35
- - [Client.*lastRequest* - the property that contains last full soap request for client logging](#clientlastrequest---the-property-that-contains-last-full-soap-request-for-client-logging)
37
+ - [Client._lastRequest_ - the property that contains last full soap request for client logging](#clientlastrequest---the-property-that-contains-last-full-soap-request-for-client-logging)
36
38
  - [Client.setEndpoint(url) - overwrite the SOAP service endpoint address](#clientsetendpointurl---overwrite-the-soap-service-endpoint-address)
37
39
  - [Client Events](#client-events)
38
40
  - [_request_](#_request_)
@@ -72,12 +74,12 @@ This module lets you connect to web services using SOAP. It also provides a ser
72
74
 
73
75
  ## Features:
74
76
 
75
- * Very simple API
76
- * Handles both RPC and Document schema types
77
- * Supports multiRef SOAP messages (thanks to [@kaven276](https://github.com/kaven276))
78
- * Support for both synchronous and asynchronous method handlers
79
- * WS-Security UsernameToken Profile 1.0
80
- * Supports [Express](http://expressjs.com/) based web server (body parser middleware can be used)
77
+ - Very simple API
78
+ - Handles both RPC and Document schema types
79
+ - Supports multiRef SOAP messages (thanks to [@kaven276](https://github.com/kaven276))
80
+ - Support for both synchronous and asynchronous method handlers
81
+ - WS-Security UsernameToken Profile 1.0
82
+ - Supports [Express](http://expressjs.com/) based web server (body parser middleware can be used)
81
83
 
82
84
  ## Install
83
85
 
@@ -94,52 +96,54 @@ Paid support can be provided as well, please contact one of the active maintaine
94
96
 
95
97
  ### soap.createClient(url[, options], callback) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.
96
98
 
97
- - `url` (*string*): A HTTP/HTTPS URL, XML or a local filesystem path.
98
- - `options` (*Object*):
99
- - `endpoint` (*string*): Override the host specified by the SOAP service in the WSDL file.
100
- - `envelopeKey` (*string*): Set a custom envelope key. (**Default:** `'soap'`)
101
- - `preserveWhitespace` (*boolean*): Preserve any leading and trailing whitespace characters in text and cdata.
102
- - `escapeXML` (*boolean*): Escape special XML characters (e.g. `&`, `>`, `<` etc) in SOAP messages. (**Default:** `true`)
103
- - `suppressStack` (*boolean*): Suppress the full stack trace for error messages.
104
- - `returnFault` (*boolean*): Return an `Invalid XML` SOAP fault upon a bad request. (**Default:** `false`)
105
- - `forceSoap12Headers` (*boolean*): Enable SOAP 1.2 compliance.
106
- - `httpClient` (*Object*): Override the built-in HttpClient object with your own. Must implement `request(rurl, data, callback, exheaders, exoptions)`.
107
- - `request` (*Object*): Override the default request module ([Axios](https://axios-http.com/) as of `v0.40.0`).
108
- - `wsdl_headers` (*Object*): Set HTTP headers with values to be sent on WSDL requests.
109
- - `wsdl_options` (*Object*): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config).
110
- - `disableCache` (*boolean*): Prevents caching WSDL files and option objects.
111
- - `wsdlCache` (*IWSDLCache*): Custom cache implementation. If not provided, defaults to caching WSDLs indefinitely.
112
- - `overridePromiseSuffix` (*string*): Override the default method name suffix of WSDL operations for Promise-based methods. If any WSDL operation name ends with `Async', you must use this option. (**Default:** `Async`)
113
- - `normalizeNames` (*boolean*): Replace non-identifier characters (`[^a-z$_0-9]`) with `_` in WSDL operation names. Note: Clients using WSDLs with two operations like `soap:method` and `soap-method` will be overwritten. In this case, you must use bracket notation instead (`client['soap:method']()`).
114
- - `namespaceArrayElements` (*boolean*): Support non-standard array semantics. JSON arrays of the form `{list: [{elem: 1}, {elem: 2}]}` will be marshalled into XML as `<list><elem>1</elem></list> <list><elem>2</elem></list>`. If `false`, it would be marshalled into `<list> <elem>1</elem> <elem>2</elem> </list>`. (**Default:** `true`)
115
- - `stream` (*boolean*): Use streams to parse the XML SOAP responses. (**Default:** `false`)
116
- - `returnSaxStream` (*boolean*): Return the SAX stream, transferring responsibility of parsing XML to the end user. Only valid when the *stream* option is set to `true`. (**Default:** `false`)
117
- - `parseReponseAttachments` (*boolean*): Treat response as multipart/related response with MTOM attachment. Reach attachments on the `lastResponseAttachments` property of SoapClient. (**Default:** `false`)
99
+ - `url` (_string_): A HTTP/HTTPS URL, XML or a local filesystem path.
100
+ - `options` (_Object_):
101
+ - `endpoint` (_string_): Override the host specified by the SOAP service in the WSDL file.
102
+ - `envelopeKey` (_string_): Set a custom envelope key. (**Default:** `'soap'`)
103
+ - `preserveWhitespace` (_boolean_): Preserve any leading and trailing whitespace characters in text and cdata.
104
+ - `escapeXML` (_boolean_): Escape special XML characters (e.g. `&`, `>`, `<` etc) in SOAP messages. (**Default:** `true`)
105
+ - `suppressStack` (_boolean_): Suppress the full stack trace for error messages.
106
+ - `returnFault` (_boolean_): Return an `Invalid XML` SOAP fault upon a bad request. (**Default:** `false`)
107
+ - `forceSoap12Headers` (_boolean_): Enable SOAP 1.2 compliance.
108
+ - `httpClient` (_Object_): Override the built-in HttpClient object with your own. Must implement `request(rurl, data, callback, exheaders, exoptions)`.
109
+ - `request` (_Object_): Override the default request module ([Axios](https://axios-http.com/) as of `v0.40.0`).
110
+ - `wsdl_headers` (_Object_): Set HTTP headers with values to be sent on WSDL requests.
111
+ - `wsdl_options` (_Object_): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config).
112
+ - `disableCache` (_boolean_): Prevents caching WSDL files and option objects.
113
+ - `wsdlCache` (_IWSDLCache_): Custom cache implementation. If not provided, defaults to caching WSDLs indefinitely.
114
+ - `overridePromiseSuffix` (_string_): Override the default method name suffix of WSDL operations for Promise-based methods. If any WSDL operation name ends with `Async', you must use this option. (**Default:** `Async`)
115
+ - `normalizeNames` (_boolean_): Replace non-identifier characters (`[^a-z$_0-9]`) with `_` in WSDL operation names. Note: Clients using WSDLs with two operations like `soap:method` and `soap-method` will be overwritten. In this case, you must use bracket notation instead (`client['soap:method']()`).
116
+ - `namespaceArrayElements` (_boolean_): Support non-standard array semantics. JSON arrays of the form `{list: [{elem: 1}, {elem: 2}]}` will be marshalled into XML as `<list><elem>1</elem></list> <list><elem>2</elem></list>`. If `false`, it would be marshalled into `<list> <elem>1</elem> <elem>2</elem> </list>`. (**Default:** `true`)
117
+ - `stream` (_boolean_): Use streams to parse the XML SOAP responses. (**Default:** `false`)
118
+ - `returnSaxStream` (_boolean_): Return the SAX stream, transferring responsibility of parsing XML to the end user. Only valid when the _stream_ option is set to `true`. (**Default:** `false`)
119
+ - `parseReponseAttachments` (_boolean_): Treat response as multipart/related response with MTOM attachment. Reach attachments on the `lastResponseAttachments` property of SoapClient. (**Default:** `false`)
118
120
  - `encoding` (_string_): response data enconding, used with `parseReponseAttachments`. (**Default:** `utf8`)
119
- - `callback` (*Function*):
120
- - `err` (*Error* | *<AggregateError>*)
121
- - `result` (*Any*)
121
+ - `callback` (_Function_):
122
+ - `err` (_Error_ | _<AggregateError>_)
123
+ - `result` (_Any_)
122
124
  - Returns: `Client`
123
125
 
124
126
  #### Example
125
127
 
126
128
  HTTP/HTTPS:
127
- ``` javascript
128
- var soap = require('soap');
129
- var url = 'http://example.com/wsdl?wsdl';
130
- var args = {name: 'value'};
131
-
132
- soap.createClient(url, {}, function(err, client) {
133
- client.MyFunction(args, function(err, result) {
134
- console.log(result);
135
- });
129
+
130
+ ```javascript
131
+ var soap = require("soap");
132
+ var url = "http://example.com/wsdl?wsdl";
133
+ var args = { name: "value" };
134
+
135
+ soap.createClient(url, {}, function (err, client) {
136
+ client.MyFunction(args, function (err, result) {
137
+ console.log(result);
136
138
  });
139
+ });
137
140
  ```
138
141
 
139
142
  XML string format:
140
- ``` javascript
141
- var soap = require('soap');
142
- var xml = `
143
+
144
+ ```javascript
145
+ var soap = require("soap");
146
+ var xml = `
143
147
  <?xml version="1.0" encoding="UTF-8"?>
144
148
  <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
145
149
  <message name="MyFunctionRequest"/>
@@ -168,169 +172,182 @@ XML string format:
168
172
  </service>
169
173
  </definitions>
170
174
  `;
171
- var args = {name: 'value'};
175
+ var args = { name: "value" };
172
176
 
173
- soap.createClient(xml, {}, function(err, client) {
174
- client.MyFunction(args, function(err, result) {
175
- console.log(result);
176
- });
177
+ soap.createClient(xml, {}, function (err, client) {
178
+ client.MyFunction(args, function (err, result) {
179
+ console.log(result);
177
180
  });
181
+ });
178
182
  ```
179
183
 
180
-
181
184
  Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
182
185
 
183
186
  ### soap.createClientAsync(url[, options]) - create a new SOAP client from a WSDL url. Also supports a local filesystem path.
184
187
 
185
188
  Construct a `Promise<Client>` with the given WSDL file.
186
189
 
187
- - `url` (*string*): A HTTP/HTTPS URL, XML or a local filesystem path.
188
- - `options` (*Object*): See [soap.createClient(url[, options], callback)](#soapcreateclienturl-options-callback---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path) for a description.
190
+ - `url` (_string_): A HTTP/HTTPS URL, XML or a local filesystem path.
191
+ - `options` (_Object_): See [soap.createClient(url[, options], callback)](#soapcreateclienturl-options-callback---create-a-new-soap-client-from-a-wsdl-url-also-supports-a-local-filesystem-path) for a description.
189
192
  - Returns: `Promise<Client>`
190
193
 
191
194
  #### Example
192
195
 
193
- ``` javascript
194
- var soap = require('soap');
195
- var url = 'http://example.com/wsdl?wsdl';
196
- var args = {name: 'value'};
197
-
198
- // then/catch
199
- soap.createClientAsync(url).then((client) => {
196
+ ```javascript
197
+ var soap = require("soap");
198
+ var url = "http://example.com/wsdl?wsdl";
199
+ var args = { name: "value" };
200
+
201
+ // then/catch
202
+ soap
203
+ .createClientAsync(url)
204
+ .then((client) => {
200
205
  return client.MyFunctionAsync(args);
201
- }).then((result) => {
206
+ })
207
+ .then((result) => {
202
208
  console.log(result);
203
209
  });
204
210
 
205
- // async/await
206
- var client = await soap.createClientAsync(url);
207
- var result = await client.MyFunctionAsync(args);
208
- console.log(result[0]);
211
+ // async/await
212
+ var client = await soap.createClientAsync(url);
213
+ var result = await client.MyFunctionAsync(args);
214
+ console.log(result[0]);
209
215
  ```
210
216
 
211
217
  Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
212
218
 
213
- ### soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.
214
- ### soap.listen(*server*, *options*) - create a new SOAP server that listens on *path* and provides *services*.
215
-
216
- - `server` (*Object*): A [http](https://nodejs.org/api/http.html) server or [Express](http://expressjs.com/) framework based server.
217
- - `path` (*string*)
218
- - `options` (*Object*): An object containing *server options* and [WSDL Options](#handling-xml-attributes-value-and-xml-wsdloptions)
219
- - `path` (*string*)
220
- - `services` (*Object*)
221
- - `xml` (*string*)
222
- - `uri` (*string*)
223
- - `pfx` (*string* | *Buffer*): The private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the key, cert and ca options.)
224
- - `key` (*string* | *Buffer*): The private key of the server in PEM format. (Could be an array of keys). (Required)
225
- - `passphrase` (*string*): The passphrase for the private key or pfx.
226
- - `cert` (*string* | *Buffer*): The certificate key of the server in PEM format. (Could be an array of certs). (Required)
227
- - `ca` (*string[]* | *Buffer[]*): Trusted certificates in PEM format. If this is omitted several well known "root" CAs will be used, like VeriSign. These are used to authorize connections.
228
- - `crl` (*string* | *string[]*: PEM encoded CRLs (Certificate Revocation List)
229
- - `ciphers` (*string*): A description of the ciphers to use or exclude, separated by `:`. The default cipher suite is:
230
- - `enableChunkedEncoding` (*boolean*): Controls chunked transfer encoding in response. Some clients (such as Windows 10's MDM enrollment SOAP client) are sensitive to transfer-encoding mode and can't accept chunked response. This option lets users disable chunked transfer encoding for such clients. (**Default:** `true`)
231
- - `services` (*Object*)
232
- - `wsdl` (*string*): An XML string that defines the service.
233
- - `callback` (*Function*): A function to run after the server has been initialized.
219
+ ### soap.listen(_server_, _path_, _services_, _wsdl_, _callback_) - create a new SOAP server that listens on _path_ and provides _services_.
220
+
221
+ ### soap.listen(_server_, _options_) - create a new SOAP server that listens on _path_ and provides _services_.
222
+
223
+ - `server` (_Object_): A [http](https://nodejs.org/api/http.html) server or [Express](http://expressjs.com/) framework based server.
224
+ - `path` (_string_)
225
+ - `options` (_Object_): An object containing _server options_ and [WSDL Options](#handling-xml-attributes-value-and-xml-wsdloptions)
226
+ - `path` (_string_)
227
+ - `services` (_Object_)
228
+ - `xml` (_string_)
229
+ - `uri` (_string_)
230
+ - `pfx` (_string_ | _Buffer_): The private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the key, cert and ca options.)
231
+ - `key` (_string_ | _Buffer_): The private key of the server in PEM format. (Could be an array of keys). (Required)
232
+ - `passphrase` (_string_): The passphrase for the private key or pfx.
233
+ - `cert` (_string_ | _Buffer_): The certificate key of the server in PEM format. (Could be an array of certs). (Required)
234
+ - `ca` (_string[]_ | _Buffer[]_): Trusted certificates in PEM format. If this is omitted several well known "root" CAs will be used, like VeriSign. These are used to authorize connections.
235
+ - `crl` (_string_ | _string[]_: PEM encoded CRLs (Certificate Revocation List)
236
+ - `ciphers` (_string_): A description of the ciphers to use or exclude, separated by `:`. The default cipher suite is:
237
+ - `enableChunkedEncoding` (_boolean_): Controls chunked transfer encoding in response. Some clients (such as Windows 10's MDM enrollment SOAP client) are sensitive to transfer-encoding mode and can't accept chunked response. This option lets users disable chunked transfer encoding for such clients. (**Default:** `true`)
238
+ - `services` (_Object_)
239
+ - `wsdl` (_string_): An XML string that defines the service.
240
+ - `callback` (_Function_): A function to run after the server has been initialized.
234
241
  - Returns: `Server`
235
242
 
236
243
  #### Example
237
244
 
238
- ``` javascript
239
- var myService = {
240
- MyService: {
241
- MyPort: {
242
- MyFunction: function(args) {
243
- return {
244
- name: args.name
245
- };
246
- },
247
-
248
- // This is how to define an asynchronous function with a callback.
249
- MyAsyncFunction: function(args, callback) {
250
- // do some work
251
- callback({
252
- name: args.name
253
- });
254
- },
255
-
256
- // This is how to define an asynchronous function with a Promise.
257
- MyPromiseFunction: function(args) {
258
- return new Promise((resolve) => {
259
- // do some work
260
- resolve({
261
- name: args.name
262
- });
263
- });
264
- },
265
-
266
- // This is how to receive incoming headers
267
- HeadersAwareFunction: function(args, cb, headers) {
268
- return {
269
- name: headers.Token
270
- };
271
- },
272
-
273
- // You can also inspect the original `req`
274
- reallyDetailedFunction: function(args, cb, headers, req) {
275
- console.log('SOAP `reallyDetailedFunction` request from ' + req.connection.remoteAddress);
276
- return {
277
- name: headers.Token
278
- };
279
- }
280
- }
281
- }
282
- };
245
+ ```javascript
246
+ var myService = {
247
+ MyService: {
248
+ MyPort: {
249
+ MyFunction: function (args) {
250
+ return {
251
+ name: args.name,
252
+ };
253
+ },
283
254
 
284
- var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');
255
+ // This is how to define an asynchronous function with a callback.
256
+ MyAsyncFunction: function (args, callback) {
257
+ // do some work
258
+ callback({
259
+ name: args.name,
260
+ });
261
+ },
285
262
 
286
- //http server example
287
- var server = http.createServer(function(request,response) {
288
- response.end('404: Not Found: ' + request.url);
289
- });
263
+ // This is how to define an asynchronous function with a Promise.
264
+ MyPromiseFunction: function (args) {
265
+ return new Promise((resolve) => {
266
+ // do some work
267
+ resolve({
268
+ name: args.name,
269
+ });
270
+ });
271
+ },
290
272
 
291
- server.listen(8000);
292
- soap.listen(server, '/wsdl', myService, xml, function(){
293
- console.log('server initialized');
294
- });
273
+ // This is how to receive incoming headers
274
+ HeadersAwareFunction: function (args, cb, headers) {
275
+ return {
276
+ name: headers.Token,
277
+ };
278
+ },
295
279
 
296
- //express server example
297
- var app = express();
298
- //body parser middleware are supported (optional)
299
- app.use(bodyParser.raw({type: function(){return true;}, limit: '5mb'}));
300
- app.listen(8001, function(){
301
- //Note: /wsdl route will be handled by soap module
302
- //and all other routes & middleware will continue to work
303
- soap.listen(app, '/wsdl', myService, xml, function(){
304
- console.log('server initialized');
305
- });
306
- });
280
+ // You can also inspect the original `req`
281
+ reallyDetailedFunction: function (args, cb, headers, req) {
282
+ console.log(
283
+ "SOAP `reallyDetailedFunction` request from " +
284
+ req.connection.remoteAddress
285
+ );
286
+ return {
287
+ name: headers.Token,
288
+ };
289
+ },
290
+ },
291
+ },
292
+ };
293
+
294
+ var xml = require("fs").readFileSync("myservice.wsdl", "utf8");
307
295
 
296
+ //http server example
297
+ var server = http.createServer(function (request, response) {
298
+ response.end("404: Not Found: " + request.url);
299
+ });
300
+
301
+ server.listen(8000);
302
+ soap.listen(server, "/wsdl", myService, xml, function () {
303
+ console.log("server initialized");
304
+ });
305
+
306
+ //express server example
307
+ var app = express();
308
+ //body parser middleware are supported (optional)
309
+ app.use(
310
+ bodyParser.raw({
311
+ type: function () {
312
+ return true;
313
+ },
314
+ limit: "5mb",
315
+ })
316
+ );
317
+ app.listen(8001, function () {
318
+ //Note: /wsdl route will be handled by soap module
319
+ //and all other routes & middleware will continue to work
320
+ soap.listen(app, "/wsdl", myService, xml, function () {
321
+ console.log("server initialized");
322
+ });
323
+ });
308
324
  ```
309
325
 
310
- ``` javascript
311
- var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');
326
+ ```javascript
327
+ var xml = require("fs").readFileSync("myservice.wsdl", "utf8");
312
328
 
313
329
  soap.listen(server, {
314
- // Server options.
315
- path: '/wsdl',
316
- services: myService,
317
- xml: xml,
318
-
319
- // WSDL options.
320
- attributesKey: 'theAttrs',
321
- valueKey: 'theVal',
322
- xmlKey: 'theXml'
330
+ // Server options.
331
+ path: "/wsdl",
332
+ services: myService,
333
+ xml: xml,
334
+
335
+ // WSDL options.
336
+ attributesKey: "theAttrs",
337
+ valueKey: "theVal",
338
+ xmlKey: "theXml",
323
339
  });
324
340
  ```
325
341
 
326
342
  ### Server Logging
327
343
 
328
344
  If the `log` method is defined, it will be called with:
345
+
329
346
  - `type`: 'received', 'replied', 'info' or 'error'.
330
347
  - `data`: The data to be logged which will be an XML for 'received' and 'replied' or a message for the other types.
331
348
  - `req`: The original request object
332
349
 
333
- ``` javascript
350
+ ```javascript
334
351
  server = soap.listen(...)
335
352
  server.log = function(type, data, req) {
336
353
  // type is 'received', 'replied', 'info' or 'error'
@@ -341,11 +358,11 @@ If the `log` method is defined, it will be called with:
341
358
 
342
359
  Server instances emit the following events:
343
360
 
344
- * request - Emitted for every received messages.
361
+ - request - Emitted for every received messages.
345
362
  The signature of the callback is `function(request, methodName)`.
346
- * response - Emitted before sending SOAP response.
363
+ - response - Emitted before sending SOAP response.
347
364
  The signature of the callback is `function(response, methodName)`.
348
- * headers - Emitted when the SOAP Headers are not empty.
365
+ - headers - Emitted when the SOAP Headers are not empty.
349
366
  The signature of the callback is `function(headers, methodName)`.
350
367
 
351
368
  The sequence order of the calls is `request`, `headers` and then the dedicated
@@ -366,31 +383,31 @@ Pass in `oneWay` object in server options. Use the following keys:
366
383
  A service method can reply with a SOAP Fault to a client by `throw`ing an
367
384
  object with a `Fault` property.
368
385
 
369
- ``` javascript
370
- throw {
371
- Fault: {
372
- Code: {
373
- Value: 'soap:Sender',
374
- Subcode: { value: 'rpc:BadArguments' }
375
- },
376
- Reason: { Text: 'Processing Error' }
377
- }
378
- };
386
+ ```javascript
387
+ throw {
388
+ Fault: {
389
+ Code: {
390
+ Value: "soap:Sender",
391
+ Subcode: { value: "rpc:BadArguments" },
392
+ },
393
+ Reason: { Text: "Processing Error" },
394
+ },
395
+ };
379
396
  ```
380
397
 
381
- To change the HTTP statusCode of the response include it on the fault. The statusCode property will not be put on the xml message.
398
+ To change the HTTP statusCode of the response include it on the fault. The statusCode property will not be put on the xml message.
382
399
 
383
- ``` javascript
384
- throw {
385
- Fault: {
386
- Code: {
387
- Value: 'soap:Sender',
388
- Subcode: { value: 'rpc:BadArguments' }
389
- },
390
- Reason: { Text: 'Processing Error' },
391
- statusCode: 500
392
- }
393
- };
400
+ ```javascript
401
+ throw {
402
+ Fault: {
403
+ Code: {
404
+ Value: "soap:Sender",
405
+ Subcode: { value: "rpc:BadArguments" },
406
+ },
407
+ Reason: { Text: "Processing Error" },
408
+ statusCode: 500,
409
+ },
410
+ };
394
411
  ```
395
412
 
396
413
  ### Server security example using PasswordDigest
@@ -398,7 +415,8 @@ To change the HTTP statusCode of the response include it on the fault. The stat
398
415
  If `server.authenticate` is not defined then no authentication will take place.
399
416
 
400
417
  Asynchronous authentication:
401
- ``` javascript
418
+
419
+ ```javascript
402
420
  server = soap.listen(...)
403
421
  server.authenticate = function(security, callback) {
404
422
  var created, nonce, password, user, token;
@@ -417,7 +435,8 @@ Asynchronous authentication:
417
435
  ```
418
436
 
419
437
  Synchronous authentication:
420
- ``` javascript
438
+
439
+ ```javascript
421
440
  server = soap.listen(...)
422
441
  server.authenticate = function(security) {
423
442
  var created, nonce, password, user, token;
@@ -433,21 +452,20 @@ The `server.authorizeConnection` method is called prior to the soap service meth
433
452
  If the method is defined and returns `false` then the incoming connection is
434
453
  terminated.
435
454
 
436
- ``` javascript
455
+ ```javascript
437
456
  server = soap.listen(...)
438
457
  server.authorizeConnection = function(req) {
439
458
  return true; // or false
440
459
  };
441
460
  ```
442
461
 
443
-
444
462
  ## SOAP Headers
445
463
 
446
464
  ### Received SOAP Headers
447
465
 
448
466
  A service method can look at the SOAP headers by providing a 3rd arguments.
449
467
 
450
- ``` javascript
468
+ ```javascript
451
469
  {
452
470
  HeadersAwareFunction: function(args, cb, headers) {
453
471
  return {
@@ -461,7 +479,7 @@ It is also possible to subscribe to the 'headers' event.
461
479
  The event is triggered before the service method is called, and only when the
462
480
  SOAP Headers are not empty.
463
481
 
464
- ``` javascript
482
+ ```javascript
465
483
  server = soap.listen(...)
466
484
  server.on('headers', function(headers, methodName) {
467
485
  // It is possible to change the value of the headers
@@ -479,20 +497,21 @@ second parameter is the name of the SOAP method that will called
479
497
  Both client & server can define SOAP headers that will be added to what they send.
480
498
  They provide the following methods to manage the headers.
481
499
 
500
+ #### _addSoapHeader_(soapHeader[, name, namespace, xmlns]) - add soapHeader to soap:Header node
482
501
 
483
- #### *addSoapHeader*(soapHeader[, name, namespace, xmlns]) - add soapHeader to soap:Header node
484
502
  ##### Parameters
485
- - `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string,
486
- or function (server only)
503
+
504
+ - `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string,
505
+ or function (server only)
487
506
 
488
507
  For servers only, `soapHeader` can be a function, which allows headers to be
489
508
  dynamically generated from information in the request. This function will be
490
509
  called with the following arguments for each received request:
491
510
 
492
- - `methodName` The name of the request method
493
- - `args` The arguments of the request
494
- - `headers` The headers in the request
495
- - `req` The original request object
511
+ - `methodName` The name of the request method
512
+ - `args` The arguments of the request
513
+ - `headers` The headers in the request
514
+ - `req` The original request object
496
515
 
497
516
  The return value of the function must be an Object({rootName: {name: 'value'}})
498
517
  or strict xml-string, which will be inserted as an outgoing header of the
@@ -500,7 +519,7 @@ response to that request.
500
519
 
501
520
  For example:
502
521
 
503
- ``` javascript
522
+ ```javascript
504
523
  server = soap.listen(...);
505
524
  server.addSoapHeader(function(methodName, args, headers, req) {
506
525
  console.log('Adding headers for method', methodName);
@@ -513,58 +532,61 @@ For example:
513
532
  ```
514
533
 
515
534
  ##### Returns
535
+
516
536
  The index where the header is inserted.
517
537
 
518
538
  ##### Optional parameters when first arg is object :
519
- - `name` Unknown parameter (it could just a empty string)
520
- - `namespace` prefix of xml namespace
521
- - `xmlns` URI
522
539
 
523
- #### *changeSoapHeader*(index, soapHeader[, name, namespace, xmlns]) - change an already existing soapHeader
540
+ - `name` Unknown parameter (it could just a empty string)
541
+ - `namespace` prefix of xml namespace
542
+ - `xmlns` URI
543
+
544
+ #### _changeSoapHeader_(index, soapHeader[, name, namespace, xmlns]) - change an already existing soapHeader
545
+
524
546
  ##### Parameters
525
- - `index` index of the header to replace with provided new value
526
- - `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string
527
- or function (server only)
528
547
 
529
- See `addSoapHeader` for how to pass a function into `soapHeader`.
548
+ - `index` index of the header to replace with provided new value
549
+ - `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string
550
+ or function (server only)
530
551
 
531
- #### *getSoapHeaders*() - return all defined headers
552
+ See `addSoapHeader` for how to pass a function into `soapHeader`.
532
553
 
533
- #### *clearSoapHeaders*() - remove all defined headers
554
+ #### _getSoapHeaders_() - return all defined headers
534
555
 
556
+ #### _clearSoapHeaders_() - remove all defined headers
535
557
 
536
558
  ## Client
537
559
 
538
- An instance of `Client` is passed to the `soap.createClient` callback. It is used to execute methods on the soap service.
560
+ An instance of `Client` is passed to the `soap.createClient` callback. It is used to execute methods on the soap service.
539
561
 
540
562
  ### Client.describe() - description of services, ports and methods as a JavaScript object
541
563
 
542
- ``` javascript
543
- client.describe() // returns
544
- {
545
- MyService: {
546
- MyPort: {
547
- MyFunction: {
548
- input: {
549
- name: 'string'
550
- }
551
- }
564
+ ```javascript
565
+ client.describe(); // returns
566
+ {
567
+ MyService: {
568
+ MyPort: {
569
+ MyFunction: {
570
+ input: {
571
+ name: "string";
552
572
  }
553
573
  }
554
574
  }
575
+ }
576
+ }
555
577
  ```
556
578
 
557
579
  ### Client.setSecurity(security) - use the specified security protocol
558
580
 
559
581
  See [Security](#security) for example usage.
560
582
 
561
- ### Client.*method*(args, callback, options) - call *method* on the SOAP service.
583
+ ### Client._method_(args, callback, options) - call _method_ on the SOAP service.
562
584
 
563
- - `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
564
- - `callback` (*Function*)
565
- - `options` (*Object*): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config). Additional options supported by `node-soap` are documented below:
566
- - `forever` (*boolean*): Enables keep-alive connections and pools them
567
- - `attachments` (*Array*): array of attachment objects. This converts the request into MTOM: _headers['Content-Type']='multipart/related; type="application/xop+xml"; start= ... '_
585
+ - `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
586
+ - `callback` (_Function_)
587
+ - `options` (_Object_): Set options for the request module on WSDL requests. If using the default request module, see [Request Config | Axios Docs](https://axios-http.com/docs/req_config). Additional options supported by `node-soap` are documented below:
588
+ - `forever` (_boolean_): Enables keep-alive connections and pools them
589
+ - `attachments` (_Array_): array of attachment objects. This converts the request into MTOM: _headers['Content-Type']='multipart/related; type="application/xop+xml"; start= ... '_
568
590
  ```
569
591
  [{
570
592
  mimetype: content mimetype,
@@ -575,41 +597,45 @@ See [Security](#security) for example usage.
575
597
  ...
576
598
  ]
577
599
  ```
578
- - `forceMTOM` (*boolean*): Send the request as MTOM even if you don't have attachments.
579
- - `forceGzip` (*boolean*): Force transfer-encoding in gzip. (**Default:** `false`)
600
+ - `forceMTOM` (_boolean_): Send the request as MTOM even if you don't have attachments.
601
+ - `forceGzip` (_boolean_): Force transfer-encoding in gzip. (**Default:** `false`)
580
602
 
581
603
  #### Example
582
604
 
583
- ``` javascript
584
- client.MyFunction({name: 'value'}, function(err, result, rawResponse, soapHeader, rawRequest) {
585
- // result is a javascript object
586
- // rawResponse is the raw xml response string
587
- // soapHeader is the response soap header as a javascript object
588
- // rawRequest is the raw xml request string
589
- })
605
+ ```javascript
606
+ client.MyFunction(
607
+ { name: "value" },
608
+ function (err, result, rawResponse, soapHeader, rawRequest) {
609
+ // result is a javascript object
610
+ // rawResponse is the raw xml response string
611
+ // soapHeader is the response soap header as a javascript object
612
+ // rawRequest is the raw xml request string
613
+ }
614
+ );
590
615
  ```
591
616
 
592
- ### Client.*method*Async(args, options) - call *method* on the SOAP service.
617
+ ### Client.*method*Async(args, options) - call _method_ on the SOAP service.
593
618
 
594
- - `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
595
- - `options` (*Object*): See [Client.*method*(args, callback, options) - call *method* on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
619
+ - `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
620
+ - `options` (_Object_): See [Client._method_(args, callback, options) - call _method_ on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
596
621
 
597
622
  #### Example
598
623
 
599
- ``` javascript
600
- client.MyFunctionAsync({name: 'value'}).then((result) => {
601
- // result is a javascript array containing result, rawResponse, soapheader, and rawRequest
602
- // result is a javascript object
603
- // rawResponse is the raw xml response string
604
- // soapHeader is the response soap header as a javascript object
605
- // rawRequest is the raw xml request string
606
- })
624
+ ```javascript
625
+ client.MyFunctionAsync({ name: "value" }).then((result) => {
626
+ // result is a javascript array containing result, rawResponse, soapheader, and rawRequest
627
+ // result is a javascript object
628
+ // rawResponse is the raw xml response string
629
+ // soapHeader is the response soap header as a javascript object
630
+ // rawRequest is the raw xml request string
631
+ });
607
632
  ```
608
633
 
609
634
  ##### Example with JSON for the `args`
635
+
610
636
  The example above uses `{name: 'value'}` as the args. This may generate a SOAP messages such as:
611
637
 
612
- ``` javascript
638
+ ```javascript
613
639
  <?xml version="1.0" encoding="utf-8"?>
614
640
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
615
641
  <soapenv:Body>
@@ -620,12 +646,13 @@ The example above uses `{name: 'value'}` as the args. This may generate a SOAP m
620
646
  </soapenv:Envelope>
621
647
  ```
622
648
 
623
- Note that the "Request" element in the output above comes from the WSDL. If an element in `args` contains no namespace prefix, the default namespace is assumed. Otherwise, you must add the namespace prefixes to the element names as necessary (e.g., `ns1:name`).
649
+ Note that the "Request" element in the output above comes from the WSDL. If an element in `args` contains no namespace prefix, the default namespace is assumed. Otherwise, you must add the namespace prefixes to the element names as necessary (e.g., `ns1:name`).
624
650
 
625
651
  Currently, when supplying JSON args, elements may not contain both child elements and a text value, even though that is allowed in the XML specification.
626
652
 
627
653
  ##### Example with XML String for the `args`
628
- You may pass in a fully-formed XML string instead the individual elements in JSON `args` and attributes that make up the XML. The XML string should not contain an XML declaration (e.g., `<?xml version="1.0" encoding="UTF-8"?>`) or a document type declaration (e.g., `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`).
654
+
655
+ You may pass in a fully-formed XML string instead the individual elements in JSON `args` and attributes that make up the XML. The XML string should not contain an XML declaration (e.g., `<?xml version="1.0" encoding="UTF-8"?>`) or a document type declaration (e.g., `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`).
629
656
 
630
657
  ```
631
658
  var args = { _xml: "<ns1:MyRootElement xmlns:ns1="http://www.example.com/v1/ns1">
@@ -633,72 +660,97 @@ You may pass in a fully-formed XML string instead the individual elements in JSO
633
660
  </ns1:MyRootElement>"
634
661
  };
635
662
  ```
636
- You must specify all of the namespaces and namespace prefixes yourself. The element(s) from the WSDL are not utilized as they were in the "Example with JSON as the `args`" example above, which automatically populated the "Request" element.
637
663
 
638
- ### Client.*service*.*port*.*method*(args, callback[, options[, extraHeaders]]) - call a *method* using a specific *service* and *port*
664
+ You must specify all of the namespaces and namespace prefixes yourself. The element(s) from the WSDL are not utilized as they were in the "Example with JSON as the `args`" example above, which automatically populated the "Request" element.
665
+
666
+ ### Client._service_._port_._method_(args, callback[, options[, extraHeaders]]) - call a _method_ using a specific _service_ and _port_
639
667
 
640
- - `args` (*Object*): Arguments that generate an XML document inside of the SOAP Body section.
641
- - `callback` (*Function*)
642
- - `options` (*Object*): See [Client.*method*(args, callback, options) - call *method* on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
643
- - `extraHeaders` (*Object*): Sets HTTP headers for the WSDL request.
668
+ - `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
669
+ - `callback` (_Function_)
670
+ - `options` (_Object_): See [Client._method_(args, callback, options) - call _method_ on the SOAP service.](#clientmethodargs-callback-options---call-method-on-the-soap-service) for a description.
671
+ - `extraHeaders` (_Object_): Sets HTTP headers for the WSDL request.
644
672
 
645
673
  #### Example
646
674
 
647
- ``` javascript
648
- client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
649
- // result is a javascript object
650
- })
675
+ ```javascript
676
+ client.MyService.MyPort.MyFunction({ name: "value" }, function (err, result) {
677
+ // result is a javascript object
678
+ });
651
679
  ```
652
680
 
653
681
  #### Options (optional)
654
- - Accepts any option that the request module accepts, see [here.](https://github.com/mikeal/request)
655
- - For example, you could set a timeout of 5 seconds on the request like this:
656
- ``` javascript
657
- client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
658
- // result is a javascript object
659
- }, {timeout: 5000})
682
+
683
+ - Accepts any option that the request module accepts, see [here.](https://github.com/mikeal/request)
684
+ - For example, you could set a timeout of 5 seconds on the request like this:
685
+
686
+ ```javascript
687
+ client.MyService.MyPort.MyFunction(
688
+ { name: "value" },
689
+ function (err, result) {
690
+ // result is a javascript object
691
+ },
692
+ { timeout: 5000 }
693
+ );
660
694
  ```
661
695
 
662
696
  - You can measure the elapsed time on the request by passing the time option:
663
- ``` javascript
664
- client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
665
- // client.lastElapsedTime - the elapsed time of the last request in milliseconds
666
- }, {time: true})
697
+
698
+ ```javascript
699
+ client.MyService.MyPort.MyFunction(
700
+ { name: "value" },
701
+ function (err, result) {
702
+ // client.lastElapsedTime - the elapsed time of the last request in milliseconds
703
+ },
704
+ { time: true }
705
+ );
667
706
  ```
668
707
 
669
708
  - Also, you could pass your soap request through a debugging proxy such as [Fiddler](http://www.telerik.com/fiddler) or [Betwixt](https://github.com/kdzwinel/betwixt).
670
- ``` javascript
671
- client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
672
- // client.lastElapsedTime - the elapsed time of the last request in milliseconds
673
- }, {
674
- proxy: {
675
- protocol: 'https',
676
- host: '127.0.0.1',
677
- port: 9000,
678
- auth: {
679
- username: 'mikeymike',
680
- password: 'rapunz3l'
681
- }
682
- }
683
- })
709
+
710
+ ```javascript
711
+ client.MyService.MyPort.MyFunction(
712
+ { name: "value" },
713
+ function (err, result) {
714
+ // client.lastElapsedTime - the elapsed time of the last request in milliseconds
715
+ },
716
+ {
717
+ proxy: {
718
+ protocol: "https",
719
+ host: "127.0.0.1",
720
+ port: 9000,
721
+ auth: {
722
+ username: "mikeymike",
723
+ password: "rapunz3l",
724
+ },
725
+ },
726
+ }
727
+ );
684
728
  ```
685
729
 
686
730
  - You can modify xml (string) before call:
687
- ``` javascript
688
- client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
689
- // client.lastElapsedTime - the elapsed time of the last request in milliseconds
690
- }, {postProcess: function(_xml) {
691
- return _xml.replace('text', 'newtext');
692
- }})
693
- ```
731
+
732
+ ```javascript
733
+ client.MyService.MyPort.MyFunction(
734
+ { name: "value" },
735
+ function (err, result) {
736
+ // client.lastElapsedTime - the elapsed time of the last request in milliseconds
737
+ },
738
+ {
739
+ postProcess: function (_xml) {
740
+ return _xml.replace("text", "newtext");
741
+ },
742
+ }
743
+ );
744
+ ```
694
745
 
695
746
  #### Extra Headers (optional)
696
747
 
697
748
  Object properties define extra HTTP headers to be sent on the request.
698
749
 
699
750
  - Add custom User-Agent:
751
+
700
752
  ```javascript
701
- client.addHttpHeader('User-Agent', `CustomUserAgent`);
753
+ client.addHttpHeader("User-Agent", `CustomUserAgent`);
702
754
  ```
703
755
 
704
756
  #### Alternative method call using callback-last pattern
@@ -706,57 +758,81 @@ client.addHttpHeader('User-Agent', `CustomUserAgent`);
706
758
  To align method call signature with node' standard callback-last patter and event allow promisification of method calls, the following method signatures are also supported:
707
759
 
708
760
  ```javascript
709
- client.MyService.MyPort.MyFunction({name: 'value'}, options, function (err, result) {
710
- // result is a javascript object
711
- })
761
+ client.MyService.MyPort.MyFunction(
762
+ { name: "value" },
763
+ options,
764
+ function (err, result) {
765
+ // result is a javascript object
766
+ }
767
+ );
712
768
 
713
- client.MyService.MyPort.MyFunction({name: 'value'}, options, extraHeaders, function (err, result) {
714
- // result is a javascript object
715
- })
769
+ client.MyService.MyPort.MyFunction(
770
+ { name: "value" },
771
+ options,
772
+ extraHeaders,
773
+ function (err, result) {
774
+ // result is a javascript object
775
+ }
776
+ );
716
777
  ```
717
778
 
718
779
  ### Overriding the namespace prefix
719
- `node-soap` is still working out some kinks regarding namespaces. If you find that an element is given the wrong namespace prefix in the request body, you can add the prefix to it's name in the containing object. I.E.:
780
+
781
+ `node-soap` is still working out some kinks regarding namespaces. If you find that an element is given the wrong namespace prefix in the request body, you can add the prefix to it's name in the containing object. I.E.:
720
782
 
721
783
  ```javascript
722
- client.MyService.MyPort.MyFunction({'ns1:name': 'value'}, function(err, result) {
723
- // request body sent with `<ns1:name`, regardless of what the namespace should have been.
724
- }, {timeout: 5000})
784
+ client.MyService.MyPort.MyFunction(
785
+ { "ns1:name": "value" },
786
+ function (err, result) {
787
+ // request body sent with `<ns1:name`, regardless of what the namespace should have been.
788
+ },
789
+ { timeout: 5000 }
790
+ );
725
791
  ```
726
792
 
727
793
  - Remove namespace prefix of param
728
794
 
729
795
  ```javascript
730
- client.MyService.MyPort.MyFunction({':name': 'value'}, function(err, result) {
731
- // request body sent with `<name`, regardless of what the namespace should have been.
732
- }, {timeout: 5000})
796
+ client.MyService.MyPort.MyFunction(
797
+ { ":name": "value" },
798
+ function (err, result) {
799
+ // request body sent with `<name`, regardless of what the namespace should have been.
800
+ },
801
+ { timeout: 5000 }
802
+ );
733
803
  ```
734
804
 
735
- ### Client.*lastRequest* - the property that contains last full soap request for client logging
805
+ ### Client._lastRequest_ - the property that contains last full soap request for client logging
736
806
 
737
807
  ### Client.setEndpoint(url) - overwrite the SOAP service endpoint address
738
808
 
739
809
  ### Client Events
810
+
740
811
  Client instances emit the following events:
741
812
 
742
813
  ### _request_
814
+
743
815
  Emitted before a request is sent. The event handler has the signature `(xml, eid)`.
744
816
 
745
817
  - _xml_ - The entire Soap request (Envelope) including headers.
746
818
  - _eid_ - The exchange id.
747
819
 
748
820
  ### _message_
821
+
749
822
  Emitted before a request is sent, but only the body is passed to the event handler. Useful if you don't want to log /store Soap headers. The event handler has the signature `(message, eid)`.
750
823
 
751
824
  - _message_ - Soap body contents.
752
825
  - _eid_ - The exchange id.
753
826
 
754
827
  ### _soapError_
828
+
755
829
  Emitted when an erroneous response is received. Useful if you want to globally log errors. The event handler has the signature `(error, eid)`.
756
830
 
757
831
  - _error_ - An error object which also contains the resoponse.
758
832
  - _eid_ - The exchange id.
833
+
759
834
  ### _response_
835
+
760
836
  Emitted after a response is received. This is emitted for all responses (both success and errors). The event handler has the signature `(body, response, eid)`
761
837
 
762
838
  - _body_ - The SOAP response body.
@@ -773,9 +849,9 @@ By default exchange ids are generated by using node-uuid but you can use options
773
849
  Example :
774
850
 
775
851
  ```javascript
776
- client.MyService.MyPort.MyFunction(args , function(err, result) {
777
-
778
- }, {exchangeId: myExchangeId})
852
+ client.MyService.MyPort.MyFunction(args, function (err, result) {}, {
853
+ exchangeId: myExchangeId,
854
+ });
779
855
  ```
780
856
 
781
857
  ## WSDL
@@ -788,18 +864,20 @@ services).
788
864
  ## WSDL.constructor(wsdl, baseURL, options):
789
865
 
790
866
  Construct a WSDL instance from either the WSDL content or the URL to the WSDL.
867
+
791
868
  #### Parameters
792
869
 
793
- - wsdl: A string wSDL or an URL to the WSDL
794
- - baseURL: base URL for the SOAP API
795
- - options: options (see source for details), use `{}` as default.
870
+ - wsdl: A string wSDL or an URL to the WSDL
871
+ - baseURL: base URL for the SOAP API
872
+ - options: options (see source for details), use `{}` as default.
796
873
 
797
874
  ### wsdl.xmlToObject(xml):
798
875
 
799
876
  Unmarshal XML to object.
800
877
 
801
878
  #### Parameters:
802
- - xml: SOAP response (XML) to unmarshal
879
+
880
+ - xml: SOAP response (XML) to unmarshal
803
881
 
804
882
  #### Returns:
805
883
 
@@ -810,16 +888,18 @@ Object containing the object types from the xml as keys.
810
888
  Marshal an object to XML
811
889
 
812
890
  #### Parameters:
813
- - object: Object to marshal
814
- - typeName: type (as per the wsdl) of the object
815
- - namespacePrefix: namespace prefix
816
- - namespaceURI: URI of the namespace
891
+
892
+ - object: Object to marshal
893
+ - typeName: type (as per the wsdl) of the object
894
+ - namespacePrefix: namespace prefix
895
+ - namespaceURI: URI of the namespace
817
896
 
818
897
  #### Returns:
819
898
 
820
899
  XML representation of object.
821
900
 
822
901
  #### Example:
902
+
823
903
  ```typescript
824
904
  // Abstracted from a real use case
825
905
  import { AxiosInstance } from 'axios';
@@ -859,154 +939,169 @@ async function samplePostCall(prospect: IProspectType) {
859
939
  }
860
940
  ```
861
941
 
862
-
863
942
  ## Security
864
943
 
865
- `node-soap` has several default security protocols. You can easily add your own
866
- as well. The interface is quite simple. Each protocol defines these optional methods:
867
- * `addOptions(options)` - a method that accepts an options arg that is eventually passed directly to `request`.
868
- * `addHeaders(headers)` - a method that accepts an argument with HTTP headers, to add new ones.
869
- * `toXML()` - a method that returns a string of XML to be appended to the SOAP headers. Not executed if `postProcess` is also defined.
870
- * `postProcess(xml, envelopeKey)` - a method that receives the the assembled request XML plus envelope key, and returns a processed string of XML. Executed before `options.postProcess`.
944
+ `node-soap` has several default security protocols. You can easily add your own
945
+ as well. The interface is quite simple. Each protocol defines these optional methods:
946
+
947
+ - `addOptions(options)` - a method that accepts an options arg that is eventually passed directly to `request`.
948
+ - `addHeaders(headers)` - a method that accepts an argument with HTTP headers, to add new ones.
949
+ - `toXML()` - a method that returns a string of XML to be appended to the SOAP headers. Not executed if `postProcess` is also defined.
950
+ - `postProcess(xml, envelopeKey)` - a method that receives the the assembled request XML plus envelope key, and returns a processed string of XML. Executed before `options.postProcess`.
871
951
 
872
952
  ### BasicAuthSecurity
873
953
 
874
- ``` javascript
875
- client.setSecurity(new soap.BasicAuthSecurity('username', 'password'));
954
+ ```javascript
955
+ client.setSecurity(new soap.BasicAuthSecurity("username", "password"));
876
956
  ```
877
957
 
878
958
  ### BearerSecurity
879
959
 
880
- ``` javascript
881
- client.setSecurity(new soap.BearerSecurity('token'));
960
+ ```javascript
961
+ client.setSecurity(new soap.BearerSecurity("token"));
882
962
  ```
883
963
 
884
964
  ### ClientSSLSecurity
885
965
 
886
966
  _Note_: If you run into issues using this protocol, consider passing these options
887
967
  as default request options to the constructor:
888
- * `rejectUnauthorized: false`
889
- * `strictSSL: false`
890
- * `secureOptions: constants.SSL_OP_NO_TLSv1_2` (this is likely needed for node >= 10.0)
968
+
969
+ - `rejectUnauthorized: false`
970
+ - `strictSSL: false`
971
+ - `secureOptions: constants.SSL_OP_NO_TLSv1_2` (this is likely needed for node >= 10.0)
891
972
 
892
973
  If you want to reuse tls sessions, you can use the option `forever: true`.
893
974
 
894
- ``` javascript
895
- client.setSecurity(new soap.ClientSSLSecurity(
896
- '/path/to/key',
897
- 'path/to/cert',
898
- '/path/to/ca-cert', /*or an array of buffer: [fs.readFileSync('/path/to/ca-cert/1', 'utf8'),
899
- 'fs.readFileSync('/path/to/ca-cert/2', 'utf8')], */
900
- { /*default request options like */
901
- // strictSSL: true,
902
- // rejectUnauthorized: false,
903
- // hostname: 'some-hostname'
904
- // secureOptions: constants.SSL_OP_NO_TLSv1_2,
905
- // forever: true,
906
- },
907
- ));
975
+ ```javascript
976
+ client.setSecurity(
977
+ new soap.ClientSSLSecurity(
978
+ "/path/to/key",
979
+ "path/to/cert",
980
+ "/path/to/ca-cert" /*or an array of buffer: [fs.readFileSync('/path/to/ca-cert/1', 'utf8'),
981
+ 'fs.readFileSync('/path/to/ca-cert/2', 'utf8')], */,
982
+ {
983
+ /*default request options like */
984
+ // strictSSL: true,
985
+ // rejectUnauthorized: false,
986
+ // hostname: 'some-hostname'
987
+ // secureOptions: constants.SSL_OP_NO_TLSv1_2,
988
+ // forever: true,
989
+ }
990
+ )
991
+ );
908
992
  ```
909
993
 
910
994
  ### ClientSSLSecurityPFX
911
995
 
912
996
  _Note_: If you run into issues using this protocol, consider passing these options
913
997
  as default request options to the constructor:
914
- * `rejectUnauthorized: false`
915
- * `strictSSL: false`
916
- * `secureOptions: constants.SSL_OP_NO_TLSv1_2` (this is likely needed for node >= 10.0)
998
+
999
+ - `rejectUnauthorized: false`
1000
+ - `strictSSL: false`
1001
+ - `secureOptions: constants.SSL_OP_NO_TLSv1_2` (this is likely needed for node >= 10.0)
917
1002
 
918
1003
  If you want to reuse tls sessions, you can use the option `forever: true`.
919
1004
 
920
- ``` javascript
921
- client.setSecurity(new soap.ClientSSLSecurityPFX(
922
- '/path/to/pfx/cert', // or a buffer: [fs.readFileSync('/path/to/pfx/cert', 'utf8'),
923
- 'path/to/optional/passphrase',
924
- { /*default request options like */
925
- // strictSSL: true,
926
- // rejectUnauthorized: false,
927
- // hostname: 'some-hostname'
928
- // secureOptions: constants.SSL_OP_NO_TLSv1_2,
929
- // forever: true,
930
- },
931
- ));
1005
+ ```javascript
1006
+ client.setSecurity(
1007
+ new soap.ClientSSLSecurityPFX(
1008
+ "/path/to/pfx/cert", // or a buffer: [fs.readFileSync('/path/to/pfx/cert', 'utf8'),
1009
+ "path/to/optional/passphrase",
1010
+ {
1011
+ /*default request options like */
1012
+ // strictSSL: true,
1013
+ // rejectUnauthorized: false,
1014
+ // hostname: 'some-hostname'
1015
+ // secureOptions: constants.SSL_OP_NO_TLSv1_2,
1016
+ // forever: true,
1017
+ }
1018
+ )
1019
+ );
932
1020
  ```
933
1021
 
934
1022
  ### WSSecurity
935
1023
 
936
1024
  `WSSecurity` implements WS-Security. UsernameToken and PasswordText/PasswordDigest is supported.
937
1025
 
938
- ``` javascript
939
- var options = {
940
- hasNonce: true,
941
- actor: 'actor'
942
- };
943
- var wsSecurity = new soap.WSSecurity('username', 'password', options)
944
- client.setSecurity(wsSecurity);
1026
+ ```javascript
1027
+ var options = {
1028
+ hasNonce: true,
1029
+ actor: "actor",
1030
+ };
1031
+ var wsSecurity = new soap.WSSecurity("username", "password", options);
1032
+ client.setSecurity(wsSecurity);
945
1033
  ```
1034
+
946
1035
  the `options` object is optional and can contain the following properties:
947
- * `passwordType`: 'PasswordDigest' or 'PasswordText' (default: `'PasswordText'`)
948
- * `hasTimeStamp`: adds Timestamp element (default: `true`)
949
- * `hasTokenCreated`: adds Created element (default: `true`)
950
- * `hasNonce`: adds Nonce element (default: `false`)
951
- * `mustUnderstand`: adds mustUnderstand=1 attribute to security tag (default: `false`)
952
- * `actor`: if set, adds Actor attribute with given value to security tag (default: `''`)
1036
+
1037
+ - `passwordType`: 'PasswordDigest' or 'PasswordText' (default: `'PasswordText'`)
1038
+ - `hasTimeStamp`: adds Timestamp element (default: `true`)
1039
+ - `hasTokenCreated`: adds Created element (default: `true`)
1040
+ - `hasNonce`: adds Nonce element (default: `false`)
1041
+ - `mustUnderstand`: adds mustUnderstand=1 attribute to security tag (default: `false`)
1042
+ - `actor`: if set, adds Actor attribute with given value to security tag (default: `''`)
953
1043
 
954
1044
  ### WSSecurityCert
955
1045
 
956
1046
  WS-Security X509 Certificate support.
957
1047
 
958
- ``` javascript
959
- var privateKey = fs.readFileSync(privateKeyPath);
960
- var publicKey = fs.readFileSync(publicKeyPath);
961
- var password = ''; // optional password
962
- var options = {
963
- hasTimeStamp: true,
964
- additionalReferences: [
965
- 'wsa:Action',
966
- 'wsa:ReplyTo',
967
- 'wsa:To',
968
- ],
969
- signerOptions: {
970
- prefix: 'ds',
971
- attrs: { Id: 'Signature' },
972
- existingPrefixes: {
973
- wsse: 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
974
- }
975
- }
976
- }
977
- var wsSecurity = new soap.WSSecurityCert(privateKey, publicKey, password, options);
978
- client.setSecurity(wsSecurity);
1048
+ ```javascript
1049
+ var privateKey = fs.readFileSync(privateKeyPath);
1050
+ var publicKey = fs.readFileSync(publicKeyPath);
1051
+ var password = ""; // optional password
1052
+ var options = {
1053
+ hasTimeStamp: true,
1054
+ additionalReferences: ["wsa:Action", "wsa:ReplyTo", "wsa:To"],
1055
+ signerOptions: {
1056
+ prefix: "ds",
1057
+ attrs: { Id: "Signature" },
1058
+ existingPrefixes: {
1059
+ wsse: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
1060
+ },
1061
+ },
1062
+ };
1063
+ var wsSecurity = new soap.WSSecurityCert(
1064
+ privateKey,
1065
+ publicKey,
1066
+ password,
1067
+ options
1068
+ );
1069
+ client.setSecurity(wsSecurity);
979
1070
  ```
980
1071
 
981
1072
  The `options` object is optional and can contain the following properties:
982
- * `hasTimeStamp`: Includes Timestamp tags (default: `true`)
983
- * `signatureTransformations`: sets the Reference Transforms Algorithm (default ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/2001/10/xml-exc-c14n#']). Type is a string array
984
- * `signatureAlgorithm`: set to `http://www.w3.org/2001/04/xmldsig-more#rsa-sha256` to use sha256
985
- * `digestAlgorithm`: set to `http://www.w3.org/2000/09/xmldsig#sha1` to use sha1 (default `http://www.w3.org/2001/04/xmlenc#sha256`)
986
- * `additionalReferences` : (optional) Array of Soap headers that need to be signed. This need to be added using `client.addSoapHeader('header')`
987
- * `excludeReferencesFromSigning`: (Optional) An array of SOAP element names to exclude from signing (e.g., `Body`, `Timestamp`, `To`, `Action`).
988
- * `signerOptions`: (optional) passes options to the XML Signer package - from (https://github.com/yaronn/xml-crypto)
989
- * `existingPrefixes`: (optional) A hash of prefixes and namespaces prefix: namespace that shouldn't be in the signature because they already exist in the xml (default: `{ 'wsse': 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' }`)
990
- * `prefix`: (optional) Adds this value as a prefix for the generated signature tags.
991
- * `attrs`: (optional) A hash of attributes and values attrName: value to add to the signature root node
992
- * `idMode`: (optional) either 'wssecurity' to generate wsse-scoped reference Id on <Body> or undefined for an unscoped reference Id
1073
+
1074
+ - `hasTimeStamp`: Includes Timestamp tags (default: `true`)
1075
+ - `signatureTransformations`: sets the Reference Transforms Algorithm (default ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/2001/10/xml-exc-c14n#']). Type is a string array
1076
+ - `signatureAlgorithm`: set to `http://www.w3.org/2001/04/xmldsig-more#rsa-sha256` to use sha256
1077
+ - `digestAlgorithm`: set to `http://www.w3.org/2000/09/xmldsig#sha1` to use sha1 (default `http://www.w3.org/2001/04/xmlenc#sha256`)
1078
+ - `additionalReferences` : (optional) Array of Soap headers that need to be signed. This need to be added using `client.addSoapHeader('header')`
1079
+ - `excludeReferencesFromSigning`: (Optional) An array of SOAP element names to exclude from signing (e.g., `Body`, `Timestamp`, `To`, `Action`).
1080
+ - `signerOptions`: (optional) passes options to the XML Signer package - from (https://github.com/yaronn/xml-crypto)
1081
+ - `existingPrefixes`: (optional) A hash of prefixes and namespaces prefix: namespace that shouldn't be in the signature because they already exist in the xml (default: `{ 'wsse': 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' }`)
1082
+ - `prefix`: (optional) Adds this value as a prefix for the generated signature tags.
1083
+ - `attrs`: (optional) A hash of attributes and values attrName: value to add to the signature root node
1084
+ - `idMode`: (optional) either 'wssecurity' to generate wsse-scoped reference Id on <Body> or undefined for an unscoped reference Id
993
1085
 
994
1086
  ### WSSecurityPlusCert
995
1087
 
996
1088
  Use WSSecurity and WSSecurityCert together.
997
1089
 
998
- ``` javascript
999
- var wsSecurity = new soap.WSSecurity(/* see WSSecurity above */);
1000
- var wsSecurityCert = new soap.WSSecurityCert(/* see WSSecurityCert above */);
1001
- var wsSecurityPlusCert = new soap.WSSecurityPlusCert(wsSecurity, wsSecurityCert);
1002
- client.setSecurity(wsSecurityPlusCert);
1090
+ ```javascript
1091
+ var wsSecurity = new soap.WSSecurity(/* see WSSecurity above */);
1092
+ var wsSecurityCert = new soap.WSSecurityCert(/* see WSSecurityCert above */);
1093
+ var wsSecurityPlusCert = new soap.WSSecurityPlusCert(
1094
+ wsSecurity,
1095
+ wsSecurityCert
1096
+ );
1097
+ client.setSecurity(wsSecurityPlusCert);
1003
1098
  ```
1004
1099
 
1005
1100
  #### Option examples
1006
1101
 
1007
1102
  `hasTimeStamp:true`
1008
1103
 
1009
- ``` xml
1104
+ ```xml
1010
1105
  <soap:Header>
1011
1106
  <wsse:Security soap:mustUnderstand="1">
1012
1107
  <wsse:BinarySecurityToken>XXX</wsse:BinarySecurityToken>
@@ -1033,7 +1128,8 @@ Use WSSecurity and WSSecurityCert together.
1033
1128
  ```
1034
1129
 
1035
1130
  `additionalReferences: ['To']`
1036
- ``` XML
1131
+
1132
+ ```XML
1037
1133
  <soap:Header>
1038
1134
  <To Id="To">localhost.com</To>
1039
1135
  <wsse:Security soap:mustUnderstand="1">
@@ -1069,7 +1165,7 @@ Use WSSecurity and WSSecurityCert together.
1069
1165
 
1070
1166
  `signerOptions.prefix:'ds'`
1071
1167
 
1072
- ``` XML
1168
+ ```XML
1073
1169
  <soap:Header>
1074
1170
  <To Id="To">localhost.com</To>
1075
1171
  <wsse:Security soap:mustUnderstand="1">
@@ -1105,7 +1201,7 @@ Use WSSecurity and WSSecurityCert together.
1105
1201
 
1106
1202
  `signerOptions.attrs:{ Id: 'signature-100', foo:'bar'}`
1107
1203
 
1108
- ``` xml
1204
+ ```xml
1109
1205
  <soap:Header>
1110
1206
  <wsse:Security soap:mustUnderstand="1">
1111
1207
  <wsse:BinarySecurityToken>XXX</wsse:BinarySecurityToken>
@@ -1130,11 +1226,12 @@ Use WSSecurity and WSSecurityCert together.
1130
1226
  </wsse:Security>
1131
1227
  </soap:Header>
1132
1228
  ```
1229
+
1133
1230
  ### WSSecurityCertWithToken
1134
1231
 
1135
1232
  WS-Security X509 Certificate support. Just like WSSecurityCert, except that it accepts the input properties as a single object, with two properties added `username` and `password`. Which if added, will add a UsernameToken Element to the xml security element.
1136
1233
 
1137
- ``` xml
1234
+ ```xml
1138
1235
  <wsse:UsernameToken>
1139
1236
  <wsse:Username>someusername</wsse:Username>
1140
1237
  <wsse:Password>someusername's password</wsse:Password>
@@ -1144,47 +1241,68 @@ WS-Security X509 Certificate support. Just like WSSecurityCert, except that it a
1144
1241
  ### NTLMSecurity
1145
1242
 
1146
1243
  Parameter invocation:
1147
- ``` javascript
1148
- client.setSecurity(new soap.NTLMSecurity('username', 'password', 'domain', 'workstation'));
1244
+
1245
+ ```javascript
1246
+ client.setSecurity(
1247
+ new soap.NTLMSecurity("username", "password", "domain", "workstation")
1248
+ );
1149
1249
  ```
1250
+
1150
1251
  This can also be set up with a JSON object, substituting values as appropriate, for example:
1151
- ``` javascript
1152
- var loginData = {username: 'username', password: 'password', domain: 'domain', workstation: 'workstation'};
1153
- client.setSecurity(new soap.NTLMSecurity(loginData));
1252
+
1253
+ ```javascript
1254
+ var loginData = {
1255
+ username: "username",
1256
+ password: "password",
1257
+ domain: "domain",
1258
+ workstation: "workstation",
1259
+ };
1260
+ client.setSecurity(new soap.NTLMSecurity(loginData));
1154
1261
  ```
1155
1262
 
1156
1263
  ## Handling XML Attributes, Value and XML (wsdlOptions).
1264
+
1157
1265
  Sometimes it is necessary to override the default behaviour of `node-soap` in order to deal with the special requirements
1158
1266
  of your code base or a third library you use. Therefore you can use the `wsdlOptions` Object, which is passed in the
1159
1267
  `#createClient()` method and could have any (or all) of the following contents:
1268
+
1160
1269
  ```javascript
1161
1270
  var wsdlOptions = {
1162
- attributesKey: 'theAttrs',
1163
- valueKey: 'theVal',
1164
- xmlKey: 'theXml'
1165
- }
1271
+ attributesKey: "theAttrs",
1272
+ valueKey: "theVal",
1273
+ xmlKey: "theXml",
1274
+ };
1166
1275
  ```
1276
+
1167
1277
  If nothing (or an empty Object `{}`) is passed to the `#createClient()` method, the `node-soap` defaults (`attributesKey: 'attributes'`, `valueKey: '$value'` and `xmlKey: '$xml'`) are used.
1168
1278
 
1169
1279
  ### Overriding the `value` key
1280
+
1170
1281
  By default, `node-soap` uses `$value` as the key for any parsed XML value which may interfere with your other code as it
1171
1282
  could be some reserved word, or the `$` in general cannot be used for a key to start with.
1172
1283
 
1173
1284
  You can define your own `valueKey` by passing it in the `wsdl_options` to the createClient call:
1285
+
1174
1286
  ```javascript
1175
1287
  var wsdlOptions = {
1176
- valueKey: 'theVal'
1288
+ valueKey: "theVal",
1177
1289
  };
1178
1290
 
1179
- soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
1180
- // your code
1181
- });
1291
+ soap.createClient(
1292
+ __dirname + "/wsdl/default_namespace.wsdl",
1293
+ wsdlOptions,
1294
+ function (err, client) {
1295
+ // your code
1296
+ }
1297
+ );
1182
1298
  ```
1183
1299
 
1184
1300
  ### Overriding the `xml` key
1301
+
1185
1302
  By default, `node-soap` uses `$xml` as the key to pass through an XML string as is; without parsing or namespacing it. It overrides all the other content that the node might have otherwise had.
1186
1303
 
1187
1304
  For example :
1305
+
1188
1306
  ```javascript
1189
1307
  {
1190
1308
  dom: {
@@ -1203,7 +1321,9 @@ For example :
1203
1321
  }
1204
1322
  };
1205
1323
  ```
1324
+
1206
1325
  could become
1326
+
1207
1327
  ```xml
1208
1328
  <tns:dom>
1209
1329
  <tns:nodeone>
@@ -1220,20 +1340,26 @@ could become
1220
1340
  ```
1221
1341
 
1222
1342
  You can define your own `xmlKey` by passing it in the `wsdl_options` object to the createClient call:
1343
+
1223
1344
  ```javascript
1224
1345
  var wsdlOptions = {
1225
- xmlKey: 'theXml'
1346
+ xmlKey: "theXml",
1226
1347
  };
1227
1348
 
1228
- soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
1229
- // your code
1230
- });
1349
+ soap.createClient(
1350
+ __dirname + "/wsdl/default_namespace.wsdl",
1351
+ wsdlOptions,
1352
+ function (err, client) {
1353
+ // your code
1354
+ }
1355
+ );
1231
1356
  ```
1232
1357
 
1233
1358
  ### Overriding the `attributes` key
1359
+
1234
1360
  By default, `node-soap` uses `attributes` as the key to define a nodes attributes.
1235
1361
 
1236
- ``` javascript
1362
+ ```javascript
1237
1363
  {
1238
1364
  parentnode: {
1239
1365
  childnode: {
@@ -1245,37 +1371,45 @@ By default, `node-soap` uses `attributes` as the key to define a nodes attribute
1245
1371
  }
1246
1372
  }
1247
1373
  ```
1374
+
1248
1375
  could become
1249
- ``` xml
1376
+
1377
+ ```xml
1250
1378
  <parentnode>
1251
1379
  <childnode name="childsname">Value</childnode>
1252
1380
  </parentnode>
1253
1381
  ```
1254
1382
 
1255
1383
  However, `attributes` may be a reserved key for some systems that actually want a node called `attributes`
1384
+
1256
1385
  ```xml
1257
1386
  <attributes>
1258
1387
  </attributes>
1259
1388
  ```
1260
1389
 
1261
1390
  You can define your own `attributesKey` by passing it in the `wsdl_options` object to the createClient call:
1391
+
1262
1392
  ```javascript
1263
1393
  var wsdlOptions = {
1264
- attributesKey: '$attributes'
1394
+ attributesKey: "$attributes",
1265
1395
  };
1266
1396
 
1267
- soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, function (err, client) {
1268
- client.method({
1269
- parentnode: {
1270
- childnode: {
1271
- $attributes: {
1272
- name: 'childsname'
1397
+ soap.createClient(
1398
+ __dirname + "/wsdl/default_namespace.wsdl",
1399
+ wsdlOptions,
1400
+ function (err, client) {
1401
+ client.method({
1402
+ parentnode: {
1403
+ childnode: {
1404
+ $attributes: {
1405
+ name: "childsname",
1406
+ },
1407
+ $value: "Value",
1273
1408
  },
1274
- $value: 'Value'
1275
- }
1276
- }
1277
- });
1278
- });
1409
+ },
1410
+ });
1411
+ }
1412
+ );
1279
1413
  ```
1280
1414
 
1281
1415
  ### Overriding imports relative paths
@@ -1312,25 +1446,30 @@ soap.createClient('https://127.0.0.1/service.wsdl', options, function(err, clien
1312
1446
  ```
1313
1447
 
1314
1448
  ### Specifying the exact namespace definition of the root element
1449
+
1315
1450
  In rare cases, you may want to precisely control the namespace definition that is included in the root element.
1316
1451
 
1317
1452
  You can specify the namespace definitions by setting the `overrideRootElement` key in the `wsdlOptions` like so:
1453
+
1318
1454
  ```javascript
1319
1455
  var wsdlOptions = {
1320
1456
  overrideRootElement: {
1321
- namespace: 'xmlns:tns',
1322
- xmlnsAttributes: [{
1323
- name: 'xmlns:ns2',
1324
- value: "http://tempuri.org/"
1325
- }, {
1326
- name: 'xmlns:ns3',
1327
- value: "http://sillypets.com/xsd"
1328
- }]
1329
- }
1457
+ namespace: "xmlns:tns",
1458
+ xmlnsAttributes: [
1459
+ {
1460
+ name: "xmlns:ns2",
1461
+ value: "http://tempuri.org/",
1462
+ },
1463
+ {
1464
+ name: "xmlns:ns3",
1465
+ value: "http://sillypets.com/xsd",
1466
+ },
1467
+ ],
1468
+ },
1330
1469
  };
1331
1470
  ```
1332
1471
 
1333
- To see it in practice, have a look at the sample files in: [test/request-response-samples/addPets__force_namespaces](https://github.com/vpulim/node-soap/tree/master/test/request-response-samples/addPets__force_namespaces)
1472
+ To see it in practice, have a look at the sample files in: [test/request-response-samples/addPets\_\_force_namespaces](https://github.com/vpulim/node-soap/tree/master/test/request-response-samples/addPets__force_namespaces)
1334
1473
 
1335
1474
  ### Custom Deserializer
1336
1475
 
@@ -1340,6 +1479,7 @@ For example if the soap response contains dates that are not in a format recogni
1340
1479
  To do so, you can pass a `customDeserializer` object in `options`. The properties of this object are the types that your deserializer handles itself.
1341
1480
 
1342
1481
  Example :
1482
+
1343
1483
  ```javascript
1344
1484
 
1345
1485
  var wsdlOptions = {
@@ -1370,53 +1510,60 @@ Example :
1370
1510
  ```
1371
1511
 
1372
1512
  ### Changing the tag formats to use self-closing (empty element) tags
1513
+
1373
1514
  The XML specification specifies that there is no semantic difference between `<Tag></Tag>` and `<Tag />`, and node-soap defaults to using the `<Tag></Tag>` format. But if your web service is particular, or if there is a stylistic preference, the `useEmptyTag` option causes tags with no contents to use the `<Tag />` format instead.
1374
1515
 
1375
1516
  ```javascript
1376
1517
  var wsdlOptions = {
1377
- useEmptyTag: true
1518
+ useEmptyTag: true,
1378
1519
  };
1379
1520
  ```
1380
1521
 
1381
1522
  For example: `{ MyTag: { attributes: { MyAttr: 'value' } } }` is:
1382
1523
 
1383
- * **Without useEmptyTag**: `<MyTag MyAttr="value"></MyTag>`
1384
- * **With useEmptyTag set to true**: `<MyTag MyAttr="value" />`
1524
+ - **Without useEmptyTag**: `<MyTag MyAttr="value"></MyTag>`
1525
+ - **With useEmptyTag set to true**: `<MyTag MyAttr="value" />`
1385
1526
 
1386
1527
  ## Handling "ignored" namespaces
1528
+
1387
1529
  If an Element in a `schema` definition depends on an Element which is present in the same namespace, normally the `tns:`
1388
1530
  namespace prefix is used to identify this Element. This is not much of a problem as long as you have just one `schema` defined
1389
1531
  (inline or in a separate file). If there are more `schema` files, the `tns:` in the generated `soap` file resolved mostly to the parent `wsdl` file,
1390
- which was obviously wrong.
1391
-
1392
- `node-soap` now handles namespace prefixes which shouldn't be resolved (because it's not necessary) as so called `ignoredNamespaces`
1393
- which default to an Array of 3 Strings (`['tns', 'targetNamespace', 'typedNamespace']`).
1394
-
1395
- If this is not sufficient for your purpose you can easily add more namespace prefixes to this Array, or override it in its entirety
1396
- by passing an `ignoredNamespaces` object within the `options` you pass in `soap.createClient()` method.
1397
-
1398
- A simple `ignoredNamespaces` object, which only adds certain namespaces could look like this:
1399
- ```
1400
- var options = {
1401
- ignoredNamespaces: {
1402
- namespaces: ['namespaceToIgnore', 'someOtherNamespace']
1403
- }
1404
- }
1405
- ```
1406
- This would extend the `ignoredNamespaces` of the `WSDL` processor to `['tns', 'targetNamespace', 'typedNamespace', 'namespaceToIgnore', 'someOtherNamespace']`.
1407
-
1408
- If you want to override the default ignored namespaces you would simply pass the following `ignoredNamespaces` object within the `options`:
1409
- ```
1410
- var options = {
1411
- ignoredNamespaces: {
1412
- namespaces: ['namespaceToIgnore', 'someOtherNamespace'],
1413
- override: true
1414
- }
1415
- }
1416
- ```
1417
- This would override the default `ignoredNamespaces` of the `WSDL` processor to `['namespaceToIgnore', 'someOtherNamespace']`. (This shouldn't be necessary, anyways).
1532
+ which was obviously wrong.
1533
+
1534
+ `node-soap` now handles namespace prefixes which shouldn't be resolved (because it's not necessary) as so called `ignoredNamespaces`
1535
+ which default to an Array of 3 Strings (`['tns', 'targetNamespace', 'typedNamespace']`).
1536
+
1537
+ If this is not sufficient for your purpose you can easily add more namespace prefixes to this Array, or override it in its entirety
1538
+ by passing an `ignoredNamespaces` object within the `options` you pass in `soap.createClient()` method.
1539
+
1540
+ A simple `ignoredNamespaces` object, which only adds certain namespaces could look like this:
1541
+
1542
+ ```
1543
+ var options = {
1544
+ ignoredNamespaces: {
1545
+ namespaces: ['namespaceToIgnore', 'someOtherNamespace']
1546
+ }
1547
+ }
1548
+ ```
1549
+
1550
+ This would extend the `ignoredNamespaces` of the `WSDL` processor to `['tns', 'targetNamespace', 'typedNamespace', 'namespaceToIgnore', 'someOtherNamespace']`.
1551
+
1552
+ If you want to override the default ignored namespaces you would simply pass the following `ignoredNamespaces` object within the `options`:
1553
+
1554
+ ```
1555
+ var options = {
1556
+ ignoredNamespaces: {
1557
+ namespaces: ['namespaceToIgnore', 'someOtherNamespace'],
1558
+ override: true
1559
+ }
1560
+ }
1561
+ ```
1562
+
1563
+ This would override the default `ignoredNamespaces` of the `WSDL` processor to `['namespaceToIgnore', 'someOtherNamespace']`. (This shouldn't be necessary, anyways).
1418
1564
 
1419
1565
  ## Handling "ignoreBaseNameSpaces" attribute
1566
+
1420
1567
  If an Element in a `schema` definition depends has a basenamespace defined but the request does not need that value, for example you have a "sentJob" with basenamespace "v20"
1421
1568
  but the request need only: <sendJob> set in the tree structure, you need to set the ignoreBaseNameSpaces to true. This is set because in a lot of workaround the wsdl structure is not correctly
1422
1569
  set or the webservice bring errors.
@@ -1425,6 +1572,7 @@ By default the attribute is set to true.
1425
1572
  An example to use:
1426
1573
 
1427
1574
  A simple `ignoredNamespaces` object, which only adds certain namespaces could look like this:
1575
+
1428
1576
  ```
1429
1577
  var options = {
1430
1578
  ignoredNamespaces: true
@@ -1433,7 +1581,7 @@ ignoredNamespaces: true
1433
1581
 
1434
1582
  ## soap-stub
1435
1583
 
1436
- Unit testing services that use soap clients can be very cumbersome. In order to get
1584
+ Unit testing services that use soap clients can be very cumbersome. In order to get
1437
1585
  around this you can use `soap-stub` in conjunction with `sinon` to stub soap with
1438
1586
  your clients.
1439
1587
 
@@ -1481,20 +1629,20 @@ describe('myService', function() {
1481
1629
  });
1482
1630
  ```
1483
1631
 
1484
-
1485
1632
  ## Contributors
1486
1633
 
1487
- * Author: [Vinay Pulim](https://github.com/vpulim)
1488
- * Active maintainers:
1489
- - [Vasily Martynov](https://github.com/w666)
1490
- * Previous maintainers (not active for a long time):
1491
- - [Joe Spencer](https://github.com/jsdevel)
1492
- - [Heinz Romirer](https://github.com/herom)
1493
- * [All Contributors](https://github.com/vpulim/node-soap/graphs/contributors)
1634
+ - Author: [Vinay Pulim](https://github.com/vpulim)
1635
+ - Active maintainers:
1636
+ - [Vasily Martynov](https://github.com/w666)
1637
+ - Previous maintainers (not active for a long time):
1638
+ - [Joe Spencer](https://github.com/jsdevel)
1639
+ - [Heinz Romirer](https://github.com/herom)
1640
+ - [All Contributors](https://github.com/vpulim/node-soap/graphs/contributors)
1494
1641
 
1495
1642
  [downloads-image]: http://img.shields.io/npm/dm/soap.svg
1496
1643
  [npm-url]: https://npmjs.org/package/soap
1497
1644
  [npm-image]: http://img.shields.io/npm/v/soap.svg
1498
-
1499
1645
  [coveralls-url]: https://coveralls.io/r/vpulim/node-soap
1500
1646
  [coveralls-image]: http://img.shields.io/coveralls/vpulim/node-soap/master.svg
1647
+ [buy-me-a-coffee-url]: https://coff.ee/vasily.m
1648
+ [buy-me-a-coffee-image]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png