soap 1.8.0 → 1.9.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 +143 -94
- package/package.json +7 -7
package/Readme.md
CHANGED
|
@@ -19,10 +19,12 @@ This module lets you connect to web services using SOAP. It also provides a serv
|
|
|
19
19
|
- [Install](#install)
|
|
20
20
|
- [Support](#support)
|
|
21
21
|
- [Module](#module)
|
|
22
|
-
- [soap
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
- [soap](#soap)
|
|
23
|
+
- [createClient(url[, options], callback)](#createclienturl-options-callback)
|
|
24
|
+
- [createClientAsync(url[, options])](#createclientasyncurl-options)
|
|
25
|
+
- [listen(_server_, _path_, _services_, _wsdl_, _callback_)](#listen_server_-path-_services_-wsdl-_callback_)
|
|
26
|
+
- [listen(_server_, _options_)](#listen_server_-options)
|
|
27
|
+
- [createServerless(_options_)](#createserverless_options_)
|
|
26
28
|
- [Server Logging](#server-logging)
|
|
27
29
|
- [Server Events](#server-events)
|
|
28
30
|
- [Server Response on one-way calls](#server-response-on-one-way-calls)
|
|
@@ -32,24 +34,36 @@ This module lets you connect to web services using SOAP. It also provides a serv
|
|
|
32
34
|
- [SOAP Headers](#soap-headers)
|
|
33
35
|
- [Received SOAP Headers](#received-soap-headers)
|
|
34
36
|
- [Outgoing SOAP Headers](#outgoing-soap-headers)
|
|
37
|
+
- [_addSoapHeader_(soapHeader[, name, namespace, xmlns])](#_addsoapheader_soapheader-name-namespace-xmlns)
|
|
38
|
+
- [changeSoapHeader(index, soapHeader[, name, namespace, xmlns])](#changesoapheaderindex-soapheader-name-namespace-xmlns)
|
|
39
|
+
- [_getSoapHeaders_()](#getsoapheaders)
|
|
40
|
+
- [_clearSoapHeaders_()](#clearsoapheaders)
|
|
35
41
|
- [Client](#client)
|
|
36
|
-
- [
|
|
37
|
-
- [
|
|
38
|
-
- [
|
|
39
|
-
- [
|
|
40
|
-
- [
|
|
42
|
+
- [_describe_()](#describe)
|
|
43
|
+
- [_setSecurity_(security)](#_setsecurity_security)
|
|
44
|
+
- [_method_(args, callback, options)](#_method_args-callback-options)
|
|
45
|
+
- [*method*Async(args, options)](#methodasyncargs-options)
|
|
46
|
+
- [_service_._port_._method_(args, callback[, options[, extraHeaders]])](#_service__port__method_args-callback-options-extraheaders)
|
|
47
|
+
- [Options (optional)](#options-optional)
|
|
48
|
+
- [Extra Headers (optional)](#extra-headers-optional)
|
|
49
|
+
- [Alternative method call using callback-last pattern](#alternative-method-call-using-callback-last-pattern)
|
|
41
50
|
- [Overriding the namespace prefix](#overriding-the-namespace-prefix)
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
51
|
+
- [_lastRequest_](#lastrequest)
|
|
52
|
+
- [_setEndpoint_(url)](#_setendpoint_url)
|
|
44
53
|
- [Client Events](#client-events)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
- [_request_](#request)
|
|
55
|
+
- [_message_](#message)
|
|
56
|
+
- [_soapError_](#soaperror)
|
|
57
|
+
- [_response_](#response)
|
|
49
58
|
- [WSDL](#wsdl)
|
|
50
|
-
- [
|
|
51
|
-
|
|
52
|
-
- [
|
|
59
|
+
- [Constructor(wsdl, baseURL, options)](#constructorwsdl-baseurl-options)
|
|
60
|
+
- [Parameters](#parameters)
|
|
61
|
+
- [xmlToObject(xml)](#xmltoobjectxml)
|
|
62
|
+
- [Parameters:](#parameters)
|
|
63
|
+
- [Returns:](#returns)
|
|
64
|
+
- [objectToXML(object, typeName, namespacePrefix, namespaceURI, ...)](#objecttoxmlobject-typename-namespaceprefix-namespaceuri-)
|
|
65
|
+
- [Parameters:](#parameters-1)
|
|
66
|
+
- [Returns:](#returns-1)
|
|
53
67
|
- [Security](#security)
|
|
54
68
|
- [BasicAuthSecurity](#basicauthsecurity)
|
|
55
69
|
- [BearerSecurity](#bearersecurity)
|
|
@@ -58,6 +72,7 @@ This module lets you connect to web services using SOAP. It also provides a serv
|
|
|
58
72
|
- [WSSecurity](#wssecurity)
|
|
59
73
|
- [WSSecurityCert](#wssecuritycert)
|
|
60
74
|
- [WSSecurityPlusCert](#wssecuritypluscert)
|
|
75
|
+
- [Option examples](#option-examples)
|
|
61
76
|
- [WSSecurityCertWithToken](#wssecuritycertwithtoken)
|
|
62
77
|
- [NTLMSecurity](#ntlmsecurity)
|
|
63
78
|
- [Handling XML Attributes, Value and XML (wsdlOptions).](#handling-xml-attributes-value-and-xml-wsdloptions)
|
|
@@ -76,7 +91,7 @@ This module lets you connect to web services using SOAP. It also provides a serv
|
|
|
76
91
|
|
|
77
92
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
78
93
|
|
|
79
|
-
|
|
94
|
+
# Features
|
|
80
95
|
|
|
81
96
|
- Very simple API
|
|
82
97
|
- Handles both RPC and Document schema types
|
|
@@ -85,20 +100,24 @@ This module lets you connect to web services using SOAP. It also provides a serv
|
|
|
85
100
|
- WS-Security UsernameToken Profile 1.0
|
|
86
101
|
- Supports [Express](http://expressjs.com/) based web server (body parser middleware can be used)
|
|
87
102
|
|
|
88
|
-
|
|
103
|
+
# Install
|
|
89
104
|
|
|
90
105
|
```
|
|
91
106
|
npm install soap
|
|
92
107
|
```
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
# Support
|
|
95
110
|
|
|
96
111
|
Community support is available through GitHub issues tab.
|
|
97
112
|
Paid support can be provided as well, please contact one of the active maintainers.
|
|
98
113
|
|
|
99
|
-
|
|
114
|
+
# Module
|
|
100
115
|
|
|
101
|
-
|
|
116
|
+
## soap
|
|
117
|
+
|
|
118
|
+
### createClient(url[, options], callback)
|
|
119
|
+
|
|
120
|
+
Creates a new SOAP client from a WSDL URL. Also supports a local filesystem path.
|
|
102
121
|
|
|
103
122
|
- `url` (_string_): A HTTP/HTTPS URL, XML or a local filesystem path.
|
|
104
123
|
- `options` (_Object_):
|
|
@@ -128,7 +147,7 @@ Paid support can be provided as well, please contact one of the active maintaine
|
|
|
128
147
|
- `result` (_Any_)
|
|
129
148
|
- Returns: `Client`
|
|
130
149
|
|
|
131
|
-
|
|
150
|
+
##### Example
|
|
132
151
|
|
|
133
152
|
HTTP/HTTPS:
|
|
134
153
|
|
|
@@ -188,12 +207,14 @@ soap.createClient(xml, {}, function (err, client) {
|
|
|
188
207
|
|
|
189
208
|
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.
|
|
190
209
|
|
|
191
|
-
###
|
|
210
|
+
### createClientAsync(url[, options])
|
|
211
|
+
|
|
212
|
+
Creates a new SOAP client from a WSDL URL. Also supports a local filesystem path.
|
|
192
213
|
|
|
193
214
|
Construct a `Promise<Client>` with the given WSDL file.
|
|
194
215
|
|
|
195
216
|
- `url` (_string_): A HTTP/HTTPS URL, XML or a local filesystem path.
|
|
196
|
-
- `options` (_Object_): See [
|
|
217
|
+
- `options` (_Object_): See [createClient(url[, options], callback)](#createclienturl-options-callback) for a description.
|
|
197
218
|
- Returns: `Promise<Client>`
|
|
198
219
|
|
|
199
220
|
#### Example
|
|
@@ -221,9 +242,13 @@ console.log(result[0]);
|
|
|
221
242
|
|
|
222
243
|
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.
|
|
223
244
|
|
|
224
|
-
###
|
|
245
|
+
### listen(_server_, _path_, _services_, _wsdl_, _callback_)
|
|
246
|
+
|
|
247
|
+
Creates a new SOAP server that listens on `path` and provides `services`.
|
|
248
|
+
|
|
249
|
+
### listen(_server_, _options_)
|
|
225
250
|
|
|
226
|
-
|
|
251
|
+
Creates a new SOAP server that listens on `path` and provides `services`.
|
|
227
252
|
|
|
228
253
|
- `server` (_Object_): A [http](https://nodejs.org/api/http.html) server or [Express](http://expressjs.com/) framework based server.
|
|
229
254
|
- `path` (_string_)
|
|
@@ -341,7 +366,9 @@ soap.listen(server, {
|
|
|
341
366
|
});
|
|
342
367
|
```
|
|
343
368
|
|
|
344
|
-
###
|
|
369
|
+
### createServerless(_options_)
|
|
370
|
+
|
|
371
|
+
Creates a new SOAP server without binding to an HTTP server.
|
|
345
372
|
|
|
346
373
|
Use this when you are running in serverless environments (for example AWS Lambda), where you receive the raw request body and must return the raw SOAP XML response yourself.
|
|
347
374
|
|
|
@@ -379,7 +406,7 @@ var server = await soap.createServerless({
|
|
|
379
406
|
}
|
|
380
407
|
```
|
|
381
408
|
|
|
382
|
-
|
|
409
|
+
## Server Logging
|
|
383
410
|
|
|
384
411
|
If the `log` method is defined, it will be called with:
|
|
385
412
|
|
|
@@ -394,7 +421,7 @@ If the `log` method is defined, it will be called with:
|
|
|
394
421
|
};
|
|
395
422
|
```
|
|
396
423
|
|
|
397
|
-
|
|
424
|
+
## Server Events
|
|
398
425
|
|
|
399
426
|
Server instances emit the following events:
|
|
400
427
|
|
|
@@ -408,7 +435,7 @@ Server instances emit the following events:
|
|
|
408
435
|
The sequence order of the calls is `request`, `headers` and then the dedicated
|
|
409
436
|
service method.
|
|
410
437
|
|
|
411
|
-
|
|
438
|
+
## Server Response on one-way calls
|
|
412
439
|
|
|
413
440
|
The so called one-way (or asynchronous) calls occur when an operation is called with no output defined in WSDL.
|
|
414
441
|
The server sends a response (defaults to status code 200 with no body) to the client disregarding the result of the operation.
|
|
@@ -418,7 +445,7 @@ Pass in `oneWay` object in server options. Use the following keys:
|
|
|
418
445
|
`emptyBody`: if true, returns an empty body, otherwise no content at all (default is false)
|
|
419
446
|
`responseCode`: default statusCode is 200, override it with this options (for example 202 for SAP standard compliant response)
|
|
420
447
|
|
|
421
|
-
|
|
448
|
+
## SOAP Fault
|
|
422
449
|
|
|
423
450
|
A service method can reply with a SOAP Fault to a client by `throw`ing an
|
|
424
451
|
object with a `Fault` property.
|
|
@@ -450,7 +477,7 @@ throw {
|
|
|
450
477
|
};
|
|
451
478
|
```
|
|
452
479
|
|
|
453
|
-
|
|
480
|
+
## Server security example using PasswordDigest
|
|
454
481
|
|
|
455
482
|
If `server.authenticate` is not defined then no authentication will take place.
|
|
456
483
|
|
|
@@ -486,7 +513,7 @@ Synchronous authentication:
|
|
|
486
513
|
};
|
|
487
514
|
```
|
|
488
515
|
|
|
489
|
-
|
|
516
|
+
## Server connection authorization
|
|
490
517
|
|
|
491
518
|
The `server.authorizeConnection` method is called prior to the soap service method.
|
|
492
519
|
If the method is defined and returns `false` then the incoming connection is
|
|
@@ -499,9 +526,9 @@ terminated.
|
|
|
499
526
|
};
|
|
500
527
|
```
|
|
501
528
|
|
|
502
|
-
|
|
529
|
+
# SOAP Headers
|
|
503
530
|
|
|
504
|
-
|
|
531
|
+
## Received SOAP Headers
|
|
505
532
|
|
|
506
533
|
A service method can look at the SOAP headers by providing a 3rd arguments.
|
|
507
534
|
|
|
@@ -532,14 +559,16 @@ First parameter is the Headers object;
|
|
|
532
559
|
second parameter is the name of the SOAP method that will called
|
|
533
560
|
(in case you need to handle the headers differently based on the method).
|
|
534
561
|
|
|
535
|
-
|
|
562
|
+
## Outgoing SOAP Headers
|
|
536
563
|
|
|
537
564
|
Both client & server can define SOAP headers that will be added to what they send.
|
|
538
565
|
They provide the following methods to manage the headers.
|
|
539
566
|
|
|
540
|
-
|
|
567
|
+
### _addSoapHeader_(soapHeader[, name, namespace, xmlns])
|
|
568
|
+
|
|
569
|
+
Adds `soapHeader` to the `soap:Header` node.
|
|
541
570
|
|
|
542
|
-
|
|
571
|
+
#### Parameters
|
|
543
572
|
|
|
544
573
|
- `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string,
|
|
545
574
|
or function (server only)
|
|
@@ -571,19 +600,21 @@ For example:
|
|
|
571
600
|
});
|
|
572
601
|
```
|
|
573
602
|
|
|
574
|
-
|
|
603
|
+
#### Returns
|
|
575
604
|
|
|
576
605
|
The index where the header is inserted.
|
|
577
606
|
|
|
578
|
-
|
|
607
|
+
#### Optional parameters when first arg is object :
|
|
579
608
|
|
|
580
609
|
- `name` Unknown parameter (it could just a empty string)
|
|
581
610
|
- `namespace` prefix of xml namespace
|
|
582
611
|
- `xmlns` URI
|
|
583
612
|
|
|
584
|
-
|
|
613
|
+
### changeSoapHeader(index, soapHeader[, name, namespace, xmlns])
|
|
585
614
|
|
|
586
|
-
|
|
615
|
+
Changes an existing `soapHeader`.
|
|
616
|
+
|
|
617
|
+
#### Parameters
|
|
587
618
|
|
|
588
619
|
- `index` index of the header to replace with provided new value
|
|
589
620
|
- `soapHeader` Object({rootName: {name: 'value'}}), strict xml-string
|
|
@@ -591,15 +622,21 @@ The index where the header is inserted.
|
|
|
591
622
|
|
|
592
623
|
See `addSoapHeader` for how to pass a function into `soapHeader`.
|
|
593
624
|
|
|
594
|
-
|
|
625
|
+
### _getSoapHeaders_()
|
|
595
626
|
|
|
596
|
-
|
|
627
|
+
Returns all defined headers.
|
|
597
628
|
|
|
598
|
-
|
|
629
|
+
### _clearSoapHeaders_()
|
|
630
|
+
|
|
631
|
+
Removes all defined headers.
|
|
632
|
+
|
|
633
|
+
# Client
|
|
599
634
|
|
|
600
635
|
An instance of `Client` is passed to the `soap.createClient` callback. It is used to execute methods on the soap service.
|
|
601
636
|
|
|
602
|
-
|
|
637
|
+
## _describe_()
|
|
638
|
+
|
|
639
|
+
Returns a description of services, ports, and methods as a JavaScript object.
|
|
603
640
|
|
|
604
641
|
```javascript
|
|
605
642
|
client.describe(); // returns
|
|
@@ -616,11 +653,15 @@ client.describe(); // returns
|
|
|
616
653
|
}
|
|
617
654
|
```
|
|
618
655
|
|
|
619
|
-
|
|
656
|
+
## _setSecurity_(security)
|
|
657
|
+
|
|
658
|
+
Uses the specified security protocol.
|
|
620
659
|
|
|
621
660
|
See [Security](#security) for example usage.
|
|
622
661
|
|
|
623
|
-
|
|
662
|
+
## _method_(args, callback, options)
|
|
663
|
+
|
|
664
|
+
Calls a _method_ on the SOAP service.
|
|
624
665
|
|
|
625
666
|
- `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
|
|
626
667
|
- `callback` (_Function_)
|
|
@@ -653,10 +694,12 @@ client.MyFunction({ name: 'value' }, function (err, result, rawResponse, soapHea
|
|
|
653
694
|
});
|
|
654
695
|
```
|
|
655
696
|
|
|
656
|
-
|
|
697
|
+
## *method*Async(args, options)
|
|
698
|
+
|
|
699
|
+
Calls a method on the SOAP service.
|
|
657
700
|
|
|
658
701
|
- `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
|
|
659
|
-
- `options` (_Object_): See [
|
|
702
|
+
- `options` (_Object_): See [method(args, callback, options)](#methodargs-callback-options) for a description.
|
|
660
703
|
|
|
661
704
|
#### Example
|
|
662
705
|
|
|
@@ -702,11 +745,13 @@ You may pass in a fully-formed XML string instead the individual elements in JSO
|
|
|
702
745
|
|
|
703
746
|
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.
|
|
704
747
|
|
|
705
|
-
|
|
748
|
+
## _service_._port_._method_(args, callback[, options[, extraHeaders]])
|
|
749
|
+
|
|
750
|
+
Calls a _method_ using a specific _service_ and _port_.
|
|
706
751
|
|
|
707
752
|
- `args` (_Object_): Arguments that generate an XML document inside of the SOAP Body section.
|
|
708
753
|
- `callback` (_Function_)
|
|
709
|
-
- `options` (_Object_): See [
|
|
754
|
+
- `options` (_Object_): See [_method_(args, callback, options)](#methodargs-callback-options) for a description.
|
|
710
755
|
- `extraHeaders` (_Object_): Sets HTTP headers for the WSDL request.
|
|
711
756
|
|
|
712
757
|
#### Example
|
|
@@ -717,7 +762,7 @@ client.MyService.MyPort.MyFunction({ name: 'value' }, function (err, result) {
|
|
|
717
762
|
});
|
|
718
763
|
```
|
|
719
764
|
|
|
720
|
-
|
|
765
|
+
### Options (optional)
|
|
721
766
|
|
|
722
767
|
- Accepts any option that the request module accepts, see [here.](https://github.com/mikeal/request)
|
|
723
768
|
- For example, you could set a timeout of 5 seconds on the request like this:
|
|
@@ -782,7 +827,7 @@ client.MyService.MyPort.MyFunction(
|
|
|
782
827
|
);
|
|
783
828
|
```
|
|
784
829
|
|
|
785
|
-
|
|
830
|
+
### Extra Headers (optional)
|
|
786
831
|
|
|
787
832
|
Object properties define extra HTTP headers to be sent on the request.
|
|
788
833
|
|
|
@@ -792,7 +837,7 @@ Object properties define extra HTTP headers to be sent on the request.
|
|
|
792
837
|
client.addHttpHeader('User-Agent', `CustomUserAgent`);
|
|
793
838
|
```
|
|
794
839
|
|
|
795
|
-
|
|
840
|
+
### Alternative method call using callback-last pattern
|
|
796
841
|
|
|
797
842
|
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:
|
|
798
843
|
|
|
@@ -806,7 +851,7 @@ client.MyService.MyPort.MyFunction({ name: 'value' }, options, extraHeaders, fun
|
|
|
806
851
|
});
|
|
807
852
|
```
|
|
808
853
|
|
|
809
|
-
|
|
854
|
+
## Overriding the namespace prefix
|
|
810
855
|
|
|
811
856
|
`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.:
|
|
812
857
|
|
|
@@ -832,11 +877,15 @@ client.MyService.MyPort.MyFunction(
|
|
|
832
877
|
);
|
|
833
878
|
```
|
|
834
879
|
|
|
835
|
-
|
|
880
|
+
## _lastRequest_
|
|
881
|
+
|
|
882
|
+
Contains the last full SOAP request for client logging.
|
|
836
883
|
|
|
837
|
-
|
|
884
|
+
## _setEndpoint_(url)
|
|
838
885
|
|
|
839
|
-
|
|
886
|
+
Overwrites the SOAP service endpoint address.
|
|
887
|
+
|
|
888
|
+
## Client Events
|
|
840
889
|
|
|
841
890
|
Client instances emit the following events:
|
|
842
891
|
|
|
@@ -882,47 +931,47 @@ Example :
|
|
|
882
931
|
client.MyService.MyPort.MyFunction(args, function (err, result) {}, { exchangeId: myExchangeId });
|
|
883
932
|
```
|
|
884
933
|
|
|
885
|
-
|
|
934
|
+
# WSDL
|
|
886
935
|
|
|
887
936
|
A WSDL instance can also be instantiated directly when you want to (un)marshal
|
|
888
937
|
messages without doing SOAP calls. This can be used when a WSDL does not contain
|
|
889
938
|
bindings for services (e.g. some Windows Communication Foundation SOAP web
|
|
890
939
|
services).
|
|
891
940
|
|
|
892
|
-
##
|
|
941
|
+
## Constructor(wsdl, baseURL, options)
|
|
893
942
|
|
|
894
943
|
Construct a WSDL instance from either the WSDL content or the URL to the WSDL.
|
|
895
944
|
|
|
896
|
-
|
|
945
|
+
### Parameters
|
|
897
946
|
|
|
898
947
|
- wsdl: a WSDL string or an URL to the WSDL
|
|
899
948
|
- baseURL: base URL for the SOAP API
|
|
900
949
|
- options: options (see source for details), use `{}` as default.
|
|
901
950
|
|
|
902
|
-
|
|
951
|
+
## xmlToObject(xml)
|
|
903
952
|
|
|
904
953
|
Unmarshal XML to object.
|
|
905
954
|
|
|
906
|
-
|
|
955
|
+
### Parameters:
|
|
907
956
|
|
|
908
957
|
- xml: SOAP response (XML) to unmarshal
|
|
909
958
|
|
|
910
|
-
|
|
959
|
+
### Returns:
|
|
911
960
|
|
|
912
961
|
Object containing the object types from the xml as keys.
|
|
913
962
|
|
|
914
|
-
|
|
963
|
+
## objectToXML(object, typeName, namespacePrefix, namespaceURI, ...)
|
|
915
964
|
|
|
916
965
|
Marshal an object to XML
|
|
917
966
|
|
|
918
|
-
|
|
967
|
+
### Parameters:
|
|
919
968
|
|
|
920
969
|
- object: Object to marshal
|
|
921
970
|
- typeName: type (as per the wsdl) of the object
|
|
922
971
|
- namespacePrefix: namespace prefix
|
|
923
972
|
- namespaceURI: URI of the namespace
|
|
924
973
|
|
|
925
|
-
|
|
974
|
+
### Returns:
|
|
926
975
|
|
|
927
976
|
XML representation of object.
|
|
928
977
|
|
|
@@ -967,7 +1016,7 @@ async function samplePostCall(prospect: IProspectType) {
|
|
|
967
1016
|
}
|
|
968
1017
|
```
|
|
969
1018
|
|
|
970
|
-
|
|
1019
|
+
# Security
|
|
971
1020
|
|
|
972
1021
|
`node-soap` has several default security protocols. You can easily add your own
|
|
973
1022
|
as well. The interface is quite simple. Each protocol defines these optional methods:
|
|
@@ -977,19 +1026,19 @@ as well. The interface is quite simple. Each protocol defines these optional met
|
|
|
977
1026
|
- `toXML()` - a method that returns a string of XML to be appended to the SOAP headers. Not executed if `postProcess` is also defined.
|
|
978
1027
|
- `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`.
|
|
979
1028
|
|
|
980
|
-
|
|
1029
|
+
## BasicAuthSecurity
|
|
981
1030
|
|
|
982
1031
|
```javascript
|
|
983
1032
|
client.setSecurity(new soap.BasicAuthSecurity('username', 'password'));
|
|
984
1033
|
```
|
|
985
1034
|
|
|
986
|
-
|
|
1035
|
+
## BearerSecurity
|
|
987
1036
|
|
|
988
1037
|
```javascript
|
|
989
1038
|
client.setSecurity(new soap.BearerSecurity('token'));
|
|
990
1039
|
```
|
|
991
1040
|
|
|
992
|
-
|
|
1041
|
+
## ClientSSLSecurity
|
|
993
1042
|
|
|
994
1043
|
_Note_: If you run into issues using this protocol, consider passing these options
|
|
995
1044
|
as default request options to the constructor:
|
|
@@ -1019,7 +1068,7 @@ client.setSecurity(
|
|
|
1019
1068
|
);
|
|
1020
1069
|
```
|
|
1021
1070
|
|
|
1022
|
-
|
|
1071
|
+
## ClientSSLSecurityPFX
|
|
1023
1072
|
|
|
1024
1073
|
_Note_: If you run into issues using this protocol, consider passing these options
|
|
1025
1074
|
as default request options to the constructor:
|
|
@@ -1047,7 +1096,7 @@ client.setSecurity(
|
|
|
1047
1096
|
);
|
|
1048
1097
|
```
|
|
1049
1098
|
|
|
1050
|
-
|
|
1099
|
+
## WSSecurity
|
|
1051
1100
|
|
|
1052
1101
|
`WSSecurity` implements WS-Security. UsernameToken and PasswordText/PasswordDigest is supported.
|
|
1053
1102
|
|
|
@@ -1070,7 +1119,7 @@ the `options` object is optional and can contain the following properties:
|
|
|
1070
1119
|
- `actor`: if set, adds Actor attribute with given value to security tag (default: `''`)
|
|
1071
1120
|
- `appendElement`: A string containing XML element to append to the end of the WSSecurity element. This can be used to add custom elements like certificates or other security tokens (default: `''`)
|
|
1072
1121
|
|
|
1073
|
-
|
|
1122
|
+
## WSSecurityCert
|
|
1074
1123
|
|
|
1075
1124
|
WS-Security X509 Certificate support.
|
|
1076
1125
|
|
|
@@ -1108,7 +1157,7 @@ The `options` object is optional and can contain the following properties:
|
|
|
1108
1157
|
- `idMode`: (optional) either 'wssecurity' to generate wsse-scoped reference Id on <Body> or undefined for an unscoped reference Id
|
|
1109
1158
|
- `appendElement`: (optional) A string containing XML element to append to the end of the WSSecurity element. This can be used to add custom elements like certificates or other security tokens.
|
|
1110
1159
|
|
|
1111
|
-
|
|
1160
|
+
## WSSecurityPlusCert
|
|
1112
1161
|
|
|
1113
1162
|
Use WSSecurity and WSSecurityCert together.
|
|
1114
1163
|
|
|
@@ -1119,7 +1168,7 @@ var wsSecurityPlusCert = new soap.WSSecurityPlusCert(wsSecurity, wsSecurityCert)
|
|
|
1119
1168
|
client.setSecurity(wsSecurityPlusCert);
|
|
1120
1169
|
```
|
|
1121
1170
|
|
|
1122
|
-
|
|
1171
|
+
### Option examples
|
|
1123
1172
|
|
|
1124
1173
|
`hasTimeStamp:true`
|
|
1125
1174
|
|
|
@@ -1268,7 +1317,7 @@ client.setSecurity(wsSecurityPlusCert);
|
|
|
1268
1317
|
</soap:Header>
|
|
1269
1318
|
```
|
|
1270
1319
|
|
|
1271
|
-
|
|
1320
|
+
## WSSecurityCertWithToken
|
|
1272
1321
|
|
|
1273
1322
|
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.
|
|
1274
1323
|
|
|
@@ -1279,7 +1328,7 @@ WS-Security X509 Certificate support. Just like WSSecurityCert, except that it a
|
|
|
1279
1328
|
</wsse:UsernameToken>
|
|
1280
1329
|
```
|
|
1281
1330
|
|
|
1282
|
-
|
|
1331
|
+
## NTLMSecurity
|
|
1283
1332
|
|
|
1284
1333
|
Parameter invocation:
|
|
1285
1334
|
|
|
@@ -1294,7 +1343,7 @@ var loginData = { username: 'username', password: 'password', domain: 'domain',
|
|
|
1294
1343
|
client.setSecurity(new soap.NTLMSecurity(loginData));
|
|
1295
1344
|
```
|
|
1296
1345
|
|
|
1297
|
-
|
|
1346
|
+
# Handling XML Attributes, Value and XML (wsdlOptions).
|
|
1298
1347
|
|
|
1299
1348
|
Sometimes it is necessary to override the default behaviour of `node-soap` in order to deal with the special requirements
|
|
1300
1349
|
of your code base or a third library you use. Therefore you can use the `wsdlOptions` Object, which is passed in the
|
|
@@ -1310,7 +1359,7 @@ var wsdlOptions = {
|
|
|
1310
1359
|
|
|
1311
1360
|
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.
|
|
1312
1361
|
|
|
1313
|
-
|
|
1362
|
+
## Overriding the `value` key
|
|
1314
1363
|
|
|
1315
1364
|
By default, `node-soap` uses `$value` as the key for any parsed XML value which may interfere with your other code as it
|
|
1316
1365
|
could be some reserved word, or the `$` in general cannot be used for a key to start with.
|
|
@@ -1327,7 +1376,7 @@ soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, funct
|
|
|
1327
1376
|
});
|
|
1328
1377
|
```
|
|
1329
1378
|
|
|
1330
|
-
|
|
1379
|
+
## Overriding the `xml` key
|
|
1331
1380
|
|
|
1332
1381
|
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.
|
|
1333
1382
|
|
|
@@ -1381,7 +1430,7 @@ soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, funct
|
|
|
1381
1430
|
});
|
|
1382
1431
|
```
|
|
1383
1432
|
|
|
1384
|
-
|
|
1433
|
+
## Overriding the `attributes` key
|
|
1385
1434
|
|
|
1386
1435
|
By default, `node-soap` uses `attributes` as the key to define a nodes attributes.
|
|
1387
1436
|
|
|
@@ -1434,7 +1483,7 @@ soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, funct
|
|
|
1434
1483
|
});
|
|
1435
1484
|
```
|
|
1436
1485
|
|
|
1437
|
-
|
|
1486
|
+
## Overriding imports relative paths
|
|
1438
1487
|
|
|
1439
1488
|
By default, WSDL and schema files import other schemas and types using relative paths.
|
|
1440
1489
|
|
|
@@ -1450,7 +1499,7 @@ soap.createClient(__dirname+'/wsdl/fixedPath/netsuite.wsdl', options, function(e
|
|
|
1450
1499
|
});
|
|
1451
1500
|
```
|
|
1452
1501
|
|
|
1453
|
-
|
|
1502
|
+
## Overriding import locations
|
|
1454
1503
|
|
|
1455
1504
|
You can override the URIs or paths of imports in the WSDL by specifying a `overrideImportLocation` function in the WSDL options.
|
|
1456
1505
|
|
|
@@ -1467,7 +1516,7 @@ soap.createClient('https://127.0.0.1/service.wsdl', options, function(err, clien
|
|
|
1467
1516
|
});
|
|
1468
1517
|
```
|
|
1469
1518
|
|
|
1470
|
-
|
|
1519
|
+
## Specifying the exact namespace definition of the root element
|
|
1471
1520
|
|
|
1472
1521
|
In rare cases, you may want to precisely control the namespace definition that is included in the root element.
|
|
1473
1522
|
|
|
@@ -1493,7 +1542,7 @@ var wsdlOptions = {
|
|
|
1493
1542
|
|
|
1494
1543
|
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)
|
|
1495
1544
|
|
|
1496
|
-
|
|
1545
|
+
## Overriding element key specification in XML
|
|
1497
1546
|
|
|
1498
1547
|
In very rare cases ([external implementation isn't matching exactly the WSDL spec?](https://github.com/vpulim/node-soap/pull/1189)),
|
|
1499
1548
|
you may want to override element XML keys in requests and/or responses.
|
|
@@ -1512,7 +1561,7 @@ var wsdlOptions = {
|
|
|
1512
1561
|
|
|
1513
1562
|
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)
|
|
1514
1563
|
|
|
1515
|
-
|
|
1564
|
+
## Custom Deserializer
|
|
1516
1565
|
|
|
1517
1566
|
Sometimes it's useful to handle deserialization in your code instead of letting node-soap do it.
|
|
1518
1567
|
For example if the soap response contains dates that are not in a format recognized by javascript, you might want to use your own function to handle them.
|
|
@@ -1550,7 +1599,7 @@ Example :
|
|
|
1550
1599
|
|
|
1551
1600
|
```
|
|
1552
1601
|
|
|
1553
|
-
|
|
1602
|
+
## Changing the tag formats to use self-closing (empty element) tags
|
|
1554
1603
|
|
|
1555
1604
|
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.
|
|
1556
1605
|
|
|
@@ -1565,7 +1614,7 @@ For example: `{ MyTag: { attributes: { MyAttr: 'value' } } }` is:
|
|
|
1565
1614
|
- **Without useEmptyTag**: `<MyTag MyAttr="value"></MyTag>`
|
|
1566
1615
|
- **With useEmptyTag set to true**: `<MyTag MyAttr="value" />`
|
|
1567
1616
|
|
|
1568
|
-
|
|
1617
|
+
# Handling "ignored" namespaces
|
|
1569
1618
|
|
|
1570
1619
|
If an Element in a `schema` definition depends on an Element which is present in the same namespace, normally the `tns:`
|
|
1571
1620
|
namespace prefix is used to identify this Element. This is not much of a problem as long as you have just one `schema` defined
|
|
@@ -1603,7 +1652,7 @@ var options = {
|
|
|
1603
1652
|
|
|
1604
1653
|
This would override the default `ignoredNamespaces` of the `WSDL` processor to `['namespaceToIgnore', 'someOtherNamespace']`. (This shouldn't be necessary, anyways).
|
|
1605
1654
|
|
|
1606
|
-
|
|
1655
|
+
# Handling "ignoreBaseNameSpaces" attribute
|
|
1607
1656
|
|
|
1608
1657
|
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"
|
|
1609
1658
|
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
|
|
@@ -1620,7 +1669,7 @@ ignoredNamespaces: true
|
|
|
1620
1669
|
}
|
|
1621
1670
|
```
|
|
1622
1671
|
|
|
1623
|
-
|
|
1672
|
+
# Contributors
|
|
1624
1673
|
|
|
1625
1674
|
- Author: [Vinay Pulim](https://github.com/vpulim)
|
|
1626
1675
|
- Active maintainers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soap",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "A minimal node SOAP client",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"follow-redirects": "^1.15.11",
|
|
14
14
|
"formidable": "^3.5.4",
|
|
15
15
|
"sax": "^1.5.0",
|
|
16
|
-
"whatwg-mimetype": "
|
|
16
|
+
"whatwg-mimetype": "5.0.0",
|
|
17
17
|
"xml-crypto": "^6.1.2"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"format": "prettier --write .",
|
|
34
34
|
"format:check": "prettier --check .",
|
|
35
35
|
"toc": "./node_modules/.bin/doctoc Readme.md --github --maxlevel 3",
|
|
36
|
-
"cover": "OPENSSL_ENABLE_SHA1_SIGNATURES=1 nyc --extension=.ts --reporter=lcov --reporter=html --reporter=text mocha --no-parallel --timeout 30000 --exit test/*-test.js test/security/*.js",
|
|
36
|
+
"cover": "OPENSSL_ENABLE_SHA1_SIGNATURES=1 TZ=UTC nyc --extension=.ts --reporter=lcov --reporter=html --reporter=text mocha --no-parallel --timeout 30000 --exit test/*-test.js test/security/*.js",
|
|
37
37
|
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js -v",
|
|
38
38
|
"docs": "typedoc --out docs",
|
|
39
|
-
"test": "mocha --timeout 15000 --bail --exit test/*-test.js test/security/*.js"
|
|
39
|
+
"test": "TZ=UTC mocha --timeout 15000 --bail --exit test/*-test.js test/security/*.js"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"soap"
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
"@types/formidable": "^3.4.6",
|
|
49
49
|
"@types/node": "^14.0.0",
|
|
50
50
|
"@types/sax": "^1.2.7",
|
|
51
|
-
"@types/whatwg-mimetype": "^
|
|
51
|
+
"@types/whatwg-mimetype": "^5.0.0",
|
|
52
52
|
"body-parser": "^2.2.0",
|
|
53
53
|
"colors": "^1.4.0",
|
|
54
54
|
"diff": "^8.0.2",
|
|
55
|
-
"doctoc": "^2.
|
|
55
|
+
"doctoc": "^2.3.0",
|
|
56
56
|
"duplexer": "~0.1.2",
|
|
57
57
|
"eslint": "^10.0.1",
|
|
58
58
|
"express": "^5.1.0",
|
|
59
59
|
"finalhandler": "^2.1.0",
|
|
60
60
|
"glob": "^13.0.0",
|
|
61
61
|
"mocha": "^11.7.4",
|
|
62
|
-
"nyc": "^
|
|
62
|
+
"nyc": "^18.0.0",
|
|
63
63
|
"prettier": "^3.6.2",
|
|
64
64
|
"readable-stream": "^4.7.0",
|
|
65
65
|
"semver": "^7.7.3",
|