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