soap 0.20.0 → 0.24.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/.editorconfig +23 -23
- package/.jshintrc +29 -29
- package/.travis.yml +22 -22
- package/CONTRIBUTING.md +52 -58
- package/History.md +52 -2
- package/LICENSE +7 -7
- package/PUBLISHING.md +28 -28
- package/Readme.md +1062 -931
- package/coverage/coverage.json +1 -0
- package/coverage/lcov-report/base.css +212 -0
- package/coverage/lcov-report/index.html +119 -0
- package/coverage/lcov-report/node-soap/index.html +93 -0
- package/coverage/lcov-report/node-soap/index.js.html +74 -0
- package/coverage/lcov-report/node-soap/lib/client.js.html +1001 -0
- package/coverage/lcov-report/node-soap/lib/http.js.html +416 -0
- package/coverage/lcov-report/node-soap/lib/index.html +171 -0
- package/coverage/lcov-report/node-soap/lib/nscontext.js.html +734 -0
- package/coverage/lcov-report/node-soap/lib/security/BasicAuthSecurity.js.html +137 -0
- package/coverage/lcov-report/node-soap/lib/security/BearerSecurity.js.html +134 -0
- package/coverage/lcov-report/node-soap/lib/security/ClientSSLSecurity.js.html +296 -0
- package/coverage/lcov-report/node-soap/lib/security/ClientSSLSecurityPFX.js.html +218 -0
- package/coverage/lcov-report/node-soap/lib/security/WSSecurity.js.html +278 -0
- package/coverage/lcov-report/node-soap/lib/security/index.html +158 -0
- package/coverage/lcov-report/node-soap/lib/security/index.js.html +92 -0
- package/coverage/lcov-report/node-soap/lib/server.js.html +1139 -0
- package/coverage/lcov-report/node-soap/lib/soap.js.html +314 -0
- package/coverage/lcov-report/node-soap/lib/utils.js.html +161 -0
- package/coverage/lcov-report/node-soap/lib/wsdl.js.html +6275 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +1 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +158 -0
- package/coverage/lcov.info +3325 -0
- package/index.js +3 -3
- package/lib/client.js +434 -425
- package/lib/http.js +129 -129
- package/lib/nscontext.js +223 -223
- package/lib/security/BasicAuthSecurity.js +24 -24
- package/lib/security/BearerSecurity.js +23 -23
- package/lib/security/ClientSSLSecurity.js +82 -65
- package/lib/security/ClientSSLSecurityPFX.js +51 -51
- package/lib/security/WSSecurity.js +90 -90
- package/lib/security/WSSecurityCert.js +78 -78
- package/lib/security/index.js +10 -10
- package/lib/security/templates/wsse-security-header.ejs +12 -12
- package/lib/security/templates/wsse-security-token.ejs +3 -3
- package/lib/server.js +474 -444
- package/lib/soap.d.ts +220 -0
- package/lib/soap.js +110 -110
- package/lib/utils.js +30 -30
- package/lib/wsdl.js +2272 -2234
- package/package.json +8 -8
- package/soap-stub.js +148 -148
- package/.npmignore +0 -2
package/lib/http.js
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2011 Vinay Pulim <vinay@milewise.com>
|
|
3
|
-
* MIT Licensed
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var url = require('url');
|
|
9
|
-
var req = require('request');
|
|
10
|
-
var debug = require('debug')('node-soap');
|
|
11
|
-
|
|
12
|
-
var VERSION = require('../package.json').version;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A class representing the http client
|
|
16
|
-
* @param {Object} [options] Options object. It allows the customization of
|
|
17
|
-
* `request` module
|
|
18
|
-
*
|
|
19
|
-
* @constructor
|
|
20
|
-
*/
|
|
21
|
-
function HttpClient(options) {
|
|
22
|
-
options = options || {};
|
|
23
|
-
this._request = options.request || req;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Build the HTTP request (method, uri, headers, ...)
|
|
28
|
-
* @param {String} rurl The resource url
|
|
29
|
-
* @param {Object|String} data The payload
|
|
30
|
-
* @param {Object} exheaders Extra http headers
|
|
31
|
-
* @param {Object} exoptions Extra options
|
|
32
|
-
* @returns {Object} The http request object for the `request` module
|
|
33
|
-
*/
|
|
34
|
-
HttpClient.prototype.buildRequest = function(rurl, data, exheaders, exoptions) {
|
|
35
|
-
var curl = url.parse(rurl);
|
|
36
|
-
var secure = curl.protocol === 'https:';
|
|
37
|
-
var host = curl.hostname;
|
|
38
|
-
var port = parseInt(curl.port, 10);
|
|
39
|
-
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
|
|
40
|
-
var method = data ? 'POST' : 'GET';
|
|
41
|
-
var headers = {
|
|
42
|
-
'User-Agent': 'node-soap/' + VERSION,
|
|
43
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
|
|
44
|
-
'Accept-Encoding': 'none',
|
|
45
|
-
'Accept-Charset': 'utf-8',
|
|
46
|
-
'Connection': 'close',
|
|
47
|
-
'Host': host + (isNaN(port) ? '' : ':' + port)
|
|
48
|
-
};
|
|
49
|
-
var attr;
|
|
50
|
-
var header;
|
|
51
|
-
var mergeOptions = ['headers'];
|
|
52
|
-
|
|
53
|
-
if (typeof data === 'string') {
|
|
54
|
-
headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
55
|
-
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exheaders = exheaders || {};
|
|
59
|
-
for (attr in exheaders) {
|
|
60
|
-
headers[attr] = exheaders[attr];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var options = {
|
|
64
|
-
uri: curl,
|
|
65
|
-
method: method,
|
|
66
|
-
headers: headers,
|
|
67
|
-
followAllRedirects: true
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
options.body = data;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
exoptions = exoptions || {};
|
|
75
|
-
for (attr in exoptions) {
|
|
76
|
-
if (mergeOptions.indexOf(attr) !== -1) {
|
|
77
|
-
for (header in exoptions[attr]) {
|
|
78
|
-
options[attr][header] = exoptions[attr][header];
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
options[attr] = exoptions[attr];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
debug('Http request: %j', options);
|
|
85
|
-
return options;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Handle the http response
|
|
90
|
-
* @param {Object} The req object
|
|
91
|
-
* @param {Object} res The res object
|
|
92
|
-
* @param {Object} body The http body
|
|
93
|
-
* @param {Object} The parsed body
|
|
94
|
-
*/
|
|
95
|
-
HttpClient.prototype.handleResponse = function(req, res, body) {
|
|
96
|
-
debug('Http response body: %j', body);
|
|
97
|
-
if (typeof body === 'string') {
|
|
98
|
-
// Remove any extra characters that appear before or after the SOAP
|
|
99
|
-
// envelope.
|
|
100
|
-
var match =
|
|
101
|
-
body.replace(/<!--[\s\S]*?-->/, "").match(/(?:<\?[^?]*\?>[\s]*)?<([^:]*):Envelope([\S\s]*)<\/\1:Envelope>/i);
|
|
102
|
-
if (match) {
|
|
103
|
-
body = match[0];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return body;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
HttpClient.prototype.request = function(rurl, data, callback, exheaders, exoptions) {
|
|
110
|
-
var self = this;
|
|
111
|
-
var options = self.buildRequest(rurl, data, exheaders, exoptions);
|
|
112
|
-
var req = self._request(options, function(err, res, body) {
|
|
113
|
-
if (err) {
|
|
114
|
-
return callback(err);
|
|
115
|
-
}
|
|
116
|
-
body = self.handleResponse(req, res, body);
|
|
117
|
-
callback(null, res, body);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return req;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
HttpClient.prototype.requestStream = function(rurl, data, exheaders, exoptions) {
|
|
124
|
-
var self = this;
|
|
125
|
-
var options = self.buildRequest(rurl, data, exheaders, exoptions);
|
|
126
|
-
return self._request(options);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
module.exports = HttpClient;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2011 Vinay Pulim <vinay@milewise.com>
|
|
3
|
+
* MIT Licensed
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var url = require('url');
|
|
9
|
+
var req = require('request');
|
|
10
|
+
var debug = require('debug')('node-soap');
|
|
11
|
+
|
|
12
|
+
var VERSION = require('../package.json').version;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A class representing the http client
|
|
16
|
+
* @param {Object} [options] Options object. It allows the customization of
|
|
17
|
+
* `request` module
|
|
18
|
+
*
|
|
19
|
+
* @constructor
|
|
20
|
+
*/
|
|
21
|
+
function HttpClient(options) {
|
|
22
|
+
options = options || {};
|
|
23
|
+
this._request = options.request || req;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Build the HTTP request (method, uri, headers, ...)
|
|
28
|
+
* @param {String} rurl The resource url
|
|
29
|
+
* @param {Object|String} data The payload
|
|
30
|
+
* @param {Object} exheaders Extra http headers
|
|
31
|
+
* @param {Object} exoptions Extra options
|
|
32
|
+
* @returns {Object} The http request object for the `request` module
|
|
33
|
+
*/
|
|
34
|
+
HttpClient.prototype.buildRequest = function(rurl, data, exheaders, exoptions) {
|
|
35
|
+
var curl = url.parse(rurl);
|
|
36
|
+
var secure = curl.protocol === 'https:';
|
|
37
|
+
var host = curl.hostname;
|
|
38
|
+
var port = parseInt(curl.port, 10);
|
|
39
|
+
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
|
|
40
|
+
var method = data ? 'POST' : 'GET';
|
|
41
|
+
var headers = {
|
|
42
|
+
'User-Agent': 'node-soap/' + VERSION,
|
|
43
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
|
|
44
|
+
'Accept-Encoding': 'none',
|
|
45
|
+
'Accept-Charset': 'utf-8',
|
|
46
|
+
'Connection': exoptions && exoptions.forever ? 'keep-alive' : 'close',
|
|
47
|
+
'Host': host + (isNaN(port) ? '' : ':' + port)
|
|
48
|
+
};
|
|
49
|
+
var attr;
|
|
50
|
+
var header;
|
|
51
|
+
var mergeOptions = ['headers'];
|
|
52
|
+
|
|
53
|
+
if (typeof data === 'string') {
|
|
54
|
+
headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
55
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exheaders = exheaders || {};
|
|
59
|
+
for (attr in exheaders) {
|
|
60
|
+
headers[attr] = exheaders[attr];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var options = {
|
|
64
|
+
uri: curl,
|
|
65
|
+
method: method,
|
|
66
|
+
headers: headers,
|
|
67
|
+
followAllRedirects: true
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
options.body = data;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
exoptions = exoptions || {};
|
|
75
|
+
for (attr in exoptions) {
|
|
76
|
+
if (mergeOptions.indexOf(attr) !== -1) {
|
|
77
|
+
for (header in exoptions[attr]) {
|
|
78
|
+
options[attr][header] = exoptions[attr][header];
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
options[attr] = exoptions[attr];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
debug('Http request: %j', options);
|
|
85
|
+
return options;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Handle the http response
|
|
90
|
+
* @param {Object} The req object
|
|
91
|
+
* @param {Object} res The res object
|
|
92
|
+
* @param {Object} body The http body
|
|
93
|
+
* @param {Object} The parsed body
|
|
94
|
+
*/
|
|
95
|
+
HttpClient.prototype.handleResponse = function(req, res, body) {
|
|
96
|
+
debug('Http response body: %j', body);
|
|
97
|
+
if (typeof body === 'string') {
|
|
98
|
+
// Remove any extra characters that appear before or after the SOAP
|
|
99
|
+
// envelope.
|
|
100
|
+
var match =
|
|
101
|
+
body.replace(/<!--[\s\S]*?-->/, "").match(/(?:<\?[^?]*\?>[\s]*)?<([^:]*):Envelope([\S\s]*)<\/\1:Envelope>/i);
|
|
102
|
+
if (match) {
|
|
103
|
+
body = match[0];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return body;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
HttpClient.prototype.request = function(rurl, data, callback, exheaders, exoptions) {
|
|
110
|
+
var self = this;
|
|
111
|
+
var options = self.buildRequest(rurl, data, exheaders, exoptions);
|
|
112
|
+
var req = self._request(options, function(err, res, body) {
|
|
113
|
+
if (err) {
|
|
114
|
+
return callback(err);
|
|
115
|
+
}
|
|
116
|
+
body = self.handleResponse(req, res, body);
|
|
117
|
+
callback(null, res, body);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return req;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
HttpClient.prototype.requestStream = function(rurl, data, exheaders, exoptions) {
|
|
124
|
+
var self = this;
|
|
125
|
+
var options = self.buildRequest(rurl, data, exheaders, exoptions);
|
|
126
|
+
return self._request(options);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
module.exports = HttpClient;
|