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