profoundjs 6.1.0 → 6.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.
@@ -1,426 +1,419 @@
1
- /*****************************************************************************\
1
+ /** ***************************************************************************\
2
2
 
3
3
  Javascript "SOAP Client" library
4
-
4
+
5
5
  @version: 2.4 - 2007.12.21
6
6
  @author: Matteo Casati - http://www.guru4.net/
7
-
8
- \*****************************************************************************/
9
7
 
10
- function SOAPClientParameters()
11
- {
12
- var _pl = new Array();
13
- this.add = function(name, value)
14
- {
15
- _pl[name] = value;
16
- return this;
17
- }
18
- this.toXml = function()
19
- {
20
- var xml = "";
21
- for(var p in _pl)
22
- {
23
- switch(typeof(_pl[p]))
24
- {
25
- case "string":
26
- case "number":
27
- case "boolean":
28
- case "object":
29
- xml += "<" + p + ">" + SOAPClientParameters._serialize(_pl[p]) + "</" + p + ">";
30
- break;
31
- default:
32
- break;
33
- }
34
- }
35
- return xml;
36
- }
37
- }
38
- SOAPClientParameters._serialize = function(o)
39
- {
40
- var s = "";
41
- switch(typeof(o))
42
- {
8
+ \*****************************************************************************/
9
+
10
+ function SOAPClientParameters() {
11
+ var _pl = [];
12
+ this.add = function(name, value) {
13
+ _pl[name] = value;
14
+ return this;
15
+ };
16
+ this.toXml = function() {
17
+ var xml = "";
18
+ for (var p in _pl) {
19
+ switch (typeof (_pl[p])) {
43
20
  case "string":
44
- s += o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); break;
45
21
  case "number":
46
22
  case "boolean":
47
- s += o.toString(); break;
48
23
  case "object":
49
- // Date
50
- if(o.constructor.toString().indexOf("function Date()") > -1)
51
- {
52
-
53
- var year = o.getFullYear().toString();
54
- var month = (o.getMonth() + 1).toString(); month = (month.length == 1) ? "0" + month : month;
55
- var date = o.getDate().toString(); date = (date.length == 1) ? "0" + date : date;
56
- var hours = o.getHours().toString(); hours = (hours.length == 1) ? "0" + hours : hours;
57
- var minutes = o.getMinutes().toString(); minutes = (minutes.length == 1) ? "0" + minutes : minutes;
58
- var seconds = o.getSeconds().toString(); seconds = (seconds.length == 1) ? "0" + seconds : seconds;
59
- var milliseconds = o.getMilliseconds().toString();
60
- var tzminutes = Math.abs(o.getTimezoneOffset());
61
- var tzhours = 0;
62
- while(tzminutes >= 60)
63
- {
64
- tzhours++;
65
- tzminutes -= 60;
66
- }
67
- tzminutes = (tzminutes.toString().length == 1) ? "0" + tzminutes.toString() : tzminutes.toString();
68
- tzhours = (tzhours.toString().length == 1) ? "0" + tzhours.toString() : tzhours.toString();
69
- var timezone = ((o.getTimezoneOffset() < 0) ? "+" : "-") + tzhours + ":" + tzminutes;
70
- s += year + "-" + month + "-" + date + "T" + hours + ":" + minutes + ":" + seconds + "." + milliseconds + timezone;
71
- }
72
- // Array
73
- else if(o.constructor.toString().indexOf("function Array()") > -1)
74
- {
75
- for(var p in o)
76
- {
77
- if(!isNaN(p)) // linear array
78
- {
79
- (/function\s+(\w*)\s*\(/ig).exec(o[p].constructor.toString());
80
- var type = RegExp.$1;
81
- switch(type)
82
- {
83
- case "":
84
- type = typeof(o[p]);
85
- case "String":
86
- type = "string"; break;
87
- case "Number":
88
- type = "int"; break;
89
- case "Boolean":
90
- type = "bool"; break;
91
- case "Date":
92
- type = "DateTime"; break;
93
- }
94
- s += "<" + type + ">" + SOAPClientParameters._serialize(o[p]) + "</" + type + ">"
95
- }
96
- else // associative array
97
- s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">"
98
- }
99
- }
100
- // Object or custom function
101
- else
102
- for(var p in o)
103
- s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">";
104
- break;
24
+ xml += "<" + p + ">" + SOAPClientParameters._serialize(_pl[p]) + "</" + p + ">";
25
+ break;
105
26
  default:
106
- break; // throw new Error(500, "SOAPClientParameters: type '" + typeof(o) + "' is not supported");
27
+ break;
28
+ }
107
29
  }
108
- return s;
30
+ return xml;
31
+ };
109
32
  }
33
+ SOAPClientParameters._serialize = function(o) {
34
+ var s = "";
35
+ var p;
36
+ switch (typeof (o)) {
37
+ case "string":
38
+ s += o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
39
+ break;
40
+ case "number":
41
+ case "boolean":
42
+ s += o.toString();
43
+ break;
44
+ case "object":
45
+ // Date
46
+ if (o.constructor.toString().indexOf("function Date()") > -1) {
47
+ var year = o.getFullYear().toString();
48
+ var month = (o.getMonth() + 1).toString();
49
+ month = (month.length == 1) ? "0" + month : month;
50
+ var date = o.getDate().toString();
51
+ date = (date.length == 1) ? "0" + date : date;
52
+ var hours = o.getHours().toString();
53
+ hours = (hours.length == 1) ? "0" + hours : hours;
54
+ var minutes = o.getMinutes().toString();
55
+ minutes = (minutes.length == 1) ? "0" + minutes : minutes;
56
+ var seconds = o.getSeconds().toString();
57
+ seconds = (seconds.length == 1) ? "0" + seconds : seconds;
58
+ var milliseconds = o.getMilliseconds().toString();
59
+ var tzminutes = Math.abs(o.getTimezoneOffset());
60
+ var tzhours = 0;
61
+ while (tzminutes >= 60) {
62
+ tzhours++;
63
+ tzminutes -= 60;
64
+ }
65
+ tzminutes = (tzminutes.toString().length == 1) ? "0" + tzminutes.toString() : tzminutes.toString();
66
+ tzhours = (tzhours.toString().length == 1) ? "0" + tzhours.toString() : tzhours.toString();
67
+ var timezone = ((o.getTimezoneOffset() < 0) ? "+" : "-") + tzhours + ":" + tzminutes;
68
+ s += year + "-" + month + "-" + date + "T" + hours + ":" + minutes + ":" + seconds + "." + milliseconds + timezone;
69
+ }
70
+ // Array
71
+ else if (o.constructor.toString().indexOf("function Array()") > -1) {
72
+ for (p in o) {
73
+ if (!isNaN(p)) {
74
+ // linear array
75
+ (/function\s+(\w*)\s*\(/ig).exec(o[p].constructor.toString());
76
+ var type = RegExp.$1;
77
+ switch (type) {
78
+ case "":
79
+ type = typeof (o[p]);
80
+ break;
81
+ case "String":
82
+ type = "string";
83
+ break;
84
+ case "Number":
85
+ type = "int";
86
+ break;
87
+ case "Boolean":
88
+ type = "bool";
89
+ break;
90
+ case "Date":
91
+ type = "DateTime";
92
+ break;
93
+ }
94
+ s += "<" + type + ">" + SOAPClientParameters._serialize(o[p]) + "</" + type + ">";
95
+ }
96
+ else {
97
+ // associative array
98
+ s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">";
99
+ }
100
+ }
101
+ }
102
+ // Object or custom function
103
+ else {
104
+ for (p in o) {
105
+ s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">";
106
+ }
107
+ }
108
+ break;
109
+ default:
110
+ break; // throw new Error(500, "SOAPClientParameters: type '" + typeof(o) + "' is not supported");
111
+ }
112
+ return s;
113
+ };
110
114
 
111
115
  function SOAPClient() {}
112
116
 
113
117
  SOAPClient.username = null;
114
118
  SOAPClient.password = null;
115
119
 
116
-
117
- SOAPClient.invoke = function(url, method, parameters, async, callback)
118
- {
119
- if(async){
120
-
121
- SOAPClient._loadWsdl(url, method, parameters, async, callback);
122
- }
123
- else
124
- return SOAPClient._loadWsdl(url, method, parameters, async, callback);
125
- }
120
+ SOAPClient.invoke = function(url, method, parameters, async, callback) {
121
+ if (async) {
122
+ SOAPClient._loadWsdl(url, method, parameters, async, callback);
123
+ }
124
+ else {
125
+ return SOAPClient._loadWsdl(url, method, parameters, async, callback);
126
+ }
127
+ };
126
128
 
127
129
  // private: wsdl cache
128
- SOAPClient_cacheWsdl = new Array();
130
+ SOAPClient_cacheWsdl = [];
129
131
 
130
132
  // private: invoke async
131
- SOAPClient._loadWsdl = function(url, method, parameters, async, callback)
132
- {
133
- // load from cache?
134
- var wsdl = SOAPClient_cacheWsdl[url];
135
- if(wsdl + "" != "" && wsdl + "" != "undefined")
136
- return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
137
- // get wsdl
138
- var xmlHttp = SOAPClient._getXmlHttp();
139
-
140
- if (SOAPClient.username && SOAPClient.password){
141
-
142
- xmlHttp.open("GET", url + "?wsdl", async, SOAPClient.username, SOAPClient.password);
143
- // Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
144
- xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.username + ":" + SOAPClient.password));
145
- }
146
-
147
- //xmlHttp.open("GET", url + "?wsdl", async);
148
- if(async)
149
- {
150
- xmlHttp.onreadystatechange = function()
151
- {
152
- if(xmlHttp.readyState == 4)
153
- SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
154
- }
155
- }
156
-
157
- xmlHttp.send(null);
158
- if (!async)
159
- return SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
160
- }
161
- SOAPClient._onLoadWsdl = function(url, method, parameters, async, callback, req)
162
- {
163
- var wsdl = req.responseXML;
164
- SOAPClient_cacheWsdl[url] = wsdl; // save a copy in cache
165
- return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
166
- }
167
- SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl)
168
- {
169
-
170
- // get namespace
171
- var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
172
-
173
- // build SOAP request
174
- var sr =
175
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
176
- "<soap:Envelope " +
177
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
178
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
179
- "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
180
- "<soap:Body>" +
181
- "<" + method + " xmlns=\"" + ns + "\">" +
182
- parameters.toXml() +
183
- "</" + method + "></soap:Body></soap:Envelope>";
184
- // send request
185
-
186
- var xmlHttp = SOAPClient._getXmlHttp();
187
-
188
- if (SOAPClient.username && SOAPClient.password){
189
-
190
- xmlHttp.open("POST", url, async, SOAPClient.username, SOAPClient.password);
191
- // Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
192
- xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.username + ":" + SOAPClient.password));
193
- }
194
- else
195
- xmlHttp.open("POST", url, async);
196
- var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
197
- xmlHttp.setRequestHeader("SOAPAction", soapaction);
198
- xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
199
- if(async)
200
- {
201
- xmlHttp.onreadystatechange = function()
202
- {
203
- if(xmlHttp.readyState == 4)
204
- SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
205
- }
206
- }
207
- xmlHttp.send(sr);
208
- if (!async)
209
- return SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
210
- }
133
+ SOAPClient._loadWsdl = function(url, method, parameters, async, callback) {
134
+ // load from cache?
135
+ var wsdl = SOAPClient_cacheWsdl[url];
136
+ if (wsdl + "" != "" && wsdl + "" != "undefined") {
137
+ return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
138
+ }
139
+ // get wsdl
140
+ var xmlHttp = SOAPClient._getXmlHttp();
211
141
 
212
- SOAPClient._onSendSoapRequest = function(method, async, callback, wsdl, req)
213
- {
214
- var o = null;
215
- var nd = SOAPClient._getElementsByTagName(req.responseXML, method + "Result");
216
- if(nd.length == 0)
217
- nd = SOAPClient._getElementsByTagName(req.responseXML, "return"); // PHP web Service?
218
- if(nd.length == 0)
219
- {
220
- if(req.responseXML.getElementsByTagName("faultcode").length > 0)
221
- {
222
- if(async || callback)
223
- o = new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
224
- else
225
- throw new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
226
- }
227
- }
228
- else
229
- o = SOAPClient._soapresult2object(nd[0], wsdl);
230
- if(callback)
231
- callback(o, req.responseXML);
232
- if(!async)
233
- return o;
234
- }
235
- SOAPClient._soapresult2object = function(node, wsdl)
236
- {
237
- var wsdlTypes = SOAPClient._getTypesFromWsdl(wsdl);
238
- return SOAPClient._node2object(node, wsdlTypes);
239
- }
240
- SOAPClient._node2object = function(node, wsdlTypes)
241
- {
242
- // null node
243
- if(node == null)
244
- return null;
245
- // text node
246
- if(node.nodeType == 3 || node.nodeType == 4)
247
- return SOAPClient._extractValue(node, wsdlTypes);
248
- // leaf node
249
- if (node.childNodes.length == 1 && (node.childNodes[0].nodeType == 3 || node.childNodes[0].nodeType == 4))
250
- return SOAPClient._node2object(node.childNodes[0], wsdlTypes);
251
- var isarray = SOAPClient._getTypeFromWsdl(node.nodeName, wsdlTypes).toLowerCase().indexOf("arrayof") != -1;
252
- // object node
253
- if(!isarray)
254
- {
255
- var obj = null;
256
- if(node.hasChildNodes())
257
- obj = new Object();
258
- for(var i = 0; i < node.childNodes.length; i++)
259
- {
260
- var p = SOAPClient._node2object(node.childNodes[i], wsdlTypes);
261
- obj[node.childNodes[i].nodeName] = p;
262
- }
263
- return obj;
264
- }
265
- // list node
266
- else
267
- {
268
- // create node ref
269
- var l = new Array();
270
- for(var i = 0; i < node.childNodes.length; i++)
271
- l[l.length] = SOAPClient._node2object(node.childNodes[i], wsdlTypes);
272
- return l;
273
- }
274
- return null;
275
- }
276
- SOAPClient._extractValue = function(node, wsdlTypes)
277
- {
278
- var value = node.nodeValue;
279
- switch(SOAPClient._getTypeFromWsdl(node.parentNode.nodeName, wsdlTypes).toLowerCase())
280
- {
281
- default:
282
- case "s:string":
283
- return (value != null) ? value + "" : "";
284
- case "s:boolean":
285
- return value + "" == "true";
286
- case "s:int":
287
- case "s:long":
288
- return (value != null) ? parseInt(value + "", 10) : 0;
289
- case "s:double":
290
- return (value != null) ? parseFloat(value + "") : 0;
291
- case "s:datetime":
292
- if(value == null)
293
- return null;
294
- else
295
- {
296
- value = value + "";
297
- value = value.substring(0, (value.lastIndexOf(".") == -1 ? value.length : value.lastIndexOf(".")));
298
- value = value.replace(/T/gi," ");
299
- value = value.replace(/-/gi,"/");
300
- var d = new Date();
301
- d.setTime(Date.parse(value));
302
- return d;
303
- }
304
- }
305
- }
306
- SOAPClient._getTypesFromWsdl = function(wsdl)
307
- {
308
- var wsdlTypes = new Array();
309
- // IE
310
- var ell = wsdl.getElementsByTagName("s:element");
311
- var useNamedItem = true;
312
- // MOZ
313
- if(ell.length == 0)
314
- {
315
- ell = wsdl.getElementsByTagName("element");
316
- useNamedItem = false;
317
- }
318
- for(var i = 0; i < ell.length; i++)
319
- {
320
- if(useNamedItem)
321
- {
322
- if(ell[i].attributes.getNamedItem("name") != null && ell[i].attributes.getNamedItem("type") != null)
323
- wsdlTypes[ell[i].attributes.getNamedItem("name").nodeValue] = ell[i].attributes.getNamedItem("type").nodeValue;
324
- }
325
- else
326
- {
327
- if(ell[i].attributes["name"] != null && ell[i].attributes["type"] != null)
328
- wsdlTypes[ell[i].attributes["name"].value] = ell[i].attributes["type"].value;
329
- }
330
- }
331
- return wsdlTypes;
332
- }
333
- SOAPClient._getTypeFromWsdl = function(elementname, wsdlTypes)
334
- {
335
- var type = wsdlTypes[elementname] + "";
336
- return (type == "undefined") ? "" : type;
337
- }
142
+ if (SOAPClient.username && SOAPClient.password) {
143
+ xmlHttp.open("GET", url + "?wsdl", async, SOAPClient.username, SOAPClient.password);
144
+ // Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
145
+ xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.username + ":" + SOAPClient.password));
146
+ }
147
+
148
+ // xmlHttp.open("GET", url + "?wsdl", async);
149
+ if (async) {
150
+ xmlHttp.onreadystatechange = function() {
151
+ if (xmlHttp.readyState == 4) {
152
+ SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
153
+ }
154
+ };
155
+ }
156
+
157
+ xmlHttp.send(null);
158
+ if (!async) {
159
+ return SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
160
+ }
161
+ };
162
+ SOAPClient._onLoadWsdl = function(url, method, parameters, async, callback, req) {
163
+ var wsdl = req.responseXML;
164
+ SOAPClient_cacheWsdl[url] = wsdl; // save a copy in cache
165
+ return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
166
+ };
167
+ SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl) {
168
+ // get namespace
169
+ var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
170
+
171
+ // build SOAP request
172
+ var sr =
173
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
174
+ "<soap:Envelope " +
175
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
176
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
177
+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
178
+ "<soap:Body>" +
179
+ "<" + method + " xmlns=\"" + ns + "\">" +
180
+ parameters.toXml() +
181
+ "</" + method + "></soap:Body></soap:Envelope>";
182
+ // send request
183
+
184
+ var xmlHttp = SOAPClient._getXmlHttp();
185
+
186
+ if (SOAPClient.username && SOAPClient.password) {
187
+ xmlHttp.open("POST", url, async, SOAPClient.username, SOAPClient.password);
188
+ // Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
189
+ xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.username + ":" + SOAPClient.password));
190
+ }
191
+ else {
192
+ xmlHttp.open("POST", url, async);
193
+ }
194
+ var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
195
+ xmlHttp.setRequestHeader("SOAPAction", soapaction);
196
+ xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
197
+ if (async) {
198
+ xmlHttp.onreadystatechange = function() {
199
+ if (xmlHttp.readyState == 4) {
200
+ SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
201
+ }
202
+ };
203
+ }
204
+ xmlHttp.send(sr);
205
+ if (!async) {
206
+ return SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
207
+ }
208
+ };
209
+
210
+ SOAPClient._onSendSoapRequest = function(method, async, callback, wsdl, req) {
211
+ var o = null;
212
+ var nd = SOAPClient._getElementsByTagName(req.responseXML, method + "Result");
213
+ if (nd.length == 0) {
214
+ nd = SOAPClient._getElementsByTagName(req.responseXML, "return");
215
+ } // PHP web Service?
216
+ if (nd.length == 0) {
217
+ if (req.responseXML.getElementsByTagName("faultcode").length > 0) {
218
+ if (async || callback) {
219
+ o = new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
220
+ }
221
+ else {
222
+ throw new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
223
+ }
224
+ }
225
+ }
226
+ else {
227
+ o = SOAPClient._soapresult2object(nd[0], wsdl);
228
+ }
229
+ if (callback) {
230
+ callback(o, req.responseXML);
231
+ }
232
+ if (!async) {
233
+ return o;
234
+ }
235
+ };
236
+ SOAPClient._soapresult2object = function(node, wsdl) {
237
+ var wsdlTypes = SOAPClient._getTypesFromWsdl(wsdl);
238
+ return SOAPClient._node2object(node, wsdlTypes);
239
+ };
240
+ SOAPClient._node2object = function(node, wsdlTypes) {
241
+ var i;
242
+ // null node
243
+ if (node == null) {
244
+ return null;
245
+ }
246
+ // text node
247
+ if (node.nodeType == 3 || node.nodeType == 4) {
248
+ return SOAPClient._extractValue(node, wsdlTypes);
249
+ }
250
+ // leaf node
251
+ if (node.childNodes.length == 1 && (node.childNodes[0].nodeType == 3 || node.childNodes[0].nodeType == 4)) {
252
+ return SOAPClient._node2object(node.childNodes[0], wsdlTypes);
253
+ }
254
+ var isarray = SOAPClient._getTypeFromWsdl(node.nodeName, wsdlTypes).toLowerCase().indexOf("arrayof") != -1;
255
+ // object node
256
+ if (!isarray) {
257
+ var obj = null;
258
+ if (node.hasChildNodes()) {
259
+ obj = {};
260
+ }
261
+ for (i = 0; i < node.childNodes.length; i++) {
262
+ var p = SOAPClient._node2object(node.childNodes[i], wsdlTypes);
263
+ obj[node.childNodes[i].nodeName] = p;
264
+ }
265
+ return obj;
266
+ }
267
+ // list node
268
+ else {
269
+ // create node ref
270
+ var l = [];
271
+ for (i = 0; i < node.childNodes.length; i++) {
272
+ l[l.length] = SOAPClient._node2object(node.childNodes[i], wsdlTypes);
273
+ }
274
+ return l;
275
+ }
276
+ };
277
+ SOAPClient._extractValue = function(node, wsdlTypes) {
278
+ var value = node.nodeValue;
279
+ switch (SOAPClient._getTypeFromWsdl(node.parentNode.nodeName, wsdlTypes).toLowerCase()) {
280
+ case "s:boolean":
281
+ return value + "" == "true";
282
+ case "s:int":
283
+ case "s:long":
284
+ return (value != null) ? parseInt(value + "", 10) : 0;
285
+ case "s:double":
286
+ return (value != null) ? parseFloat(value + "") : 0;
287
+ case "s:datetime":
288
+ if (value == null) {
289
+ return null;
290
+ }
291
+ else {
292
+ value = value + "";
293
+ value = value.substring(0, (value.lastIndexOf(".") == -1 ? value.length : value.lastIndexOf(".")));
294
+ value = value.replace(/T/gi, " ");
295
+ value = value.replace(/-/gi, "/");
296
+ var d = new Date();
297
+ d.setTime(Date.parse(value));
298
+ return d;
299
+ }
300
+ case "s:string":
301
+ default:
302
+ return (value != null) ? value + "" : "";
303
+ }
304
+ };
305
+ SOAPClient._getTypesFromWsdl = function(wsdl) {
306
+ var wsdlTypes = [];
307
+ // IE
308
+ var ell = wsdl.getElementsByTagName("s:element");
309
+ var useNamedItem = true;
310
+ // MOZ
311
+ if (ell.length == 0) {
312
+ ell = wsdl.getElementsByTagName("element");
313
+ useNamedItem = false;
314
+ }
315
+ for (var i = 0; i < ell.length; i++) {
316
+ if (useNamedItem) {
317
+ if (ell[i].attributes.getNamedItem("name") != null && ell[i].attributes.getNamedItem("type") != null) {
318
+ wsdlTypes[ell[i].attributes.getNamedItem("name").nodeValue] = ell[i].attributes.getNamedItem("type").nodeValue;
319
+ }
320
+ }
321
+ else {
322
+ if (ell[i].attributes["name"] != null && ell[i].attributes["type"] != null) {
323
+ wsdlTypes[ell[i].attributes["name"].value] = ell[i].attributes["type"].value;
324
+ }
325
+ }
326
+ }
327
+ return wsdlTypes;
328
+ };
329
+ SOAPClient._getTypeFromWsdl = function(elementname, wsdlTypes) {
330
+ var type = wsdlTypes[elementname] + "";
331
+ return (type == "undefined") ? "" : type;
332
+ };
338
333
  // private: utils
339
- SOAPClient._getElementsByTagName = function(document, tagName)
340
- {
341
- try
342
- {
343
- // trying to get node omitting any namespaces (latest versions of MSXML.XMLDocument)
344
- return document.selectNodes(".//*[local-name()=\""+ tagName +"\"]");
345
- }
346
- catch (ex) {}
347
- // old XML parser support
348
- return document.getElementsByTagName(tagName);
349
- }
334
+ SOAPClient._getElementsByTagName = function(document, tagName) {
335
+ try {
336
+ // trying to get node omitting any namespaces (latest versions of MSXML.XMLDocument)
337
+ return document.selectNodes(".//*[local-name()=\"" + tagName + "\"]");
338
+ }
339
+ catch (ex) {
340
+ }
341
+ // old XML parser support
342
+ return document.getElementsByTagName(tagName);
343
+ };
350
344
  // private: xmlhttp factory
351
- SOAPClient._getXmlHttp = function()
352
- {
353
- try
354
- {
355
- if(window.XMLHttpRequest)
356
- {
357
- var req = new XMLHttpRequest();
358
- // some versions of Moz do not support the readyState property and the onreadystate event so we patch it!
359
- if(req.readyState == null)
360
- {
361
- req.readyState = 1;
362
- req.addEventListener("load",
363
- function()
364
- {
365
- req.readyState = 4;
366
- if(typeof req.onreadystatechange == "function")
367
- req.onreadystatechange();
368
- },
369
- false);
370
- }
371
- return req;
372
- }
373
- if(window.ActiveXObject)
374
- return new ActiveXObject(SOAPClient._getXmlHttpProgID());
375
- }
376
- catch (ex) {}
377
- throw new Error("Your browser does not support XmlHttp objects");
378
- }
379
- SOAPClient._getXmlHttpProgID = function()
380
- {
381
- if(SOAPClient._getXmlHttpProgID.progid)
382
- return SOAPClient._getXmlHttpProgID.progid;
383
- var progids = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
384
- var o;
385
- for(var i = 0; i < progids.length; i++)
386
- {
387
- try
388
- {
389
- o = new ActiveXObject(progids[i]);
390
- return SOAPClient._getXmlHttpProgID.progid = progids[i];
391
- }
392
- catch (ex) {};
393
- }
394
- throw new Error("Could not find an installed XML parser");
395
- }
345
+ SOAPClient._getXmlHttp = function() {
346
+ try {
347
+ if (window.XMLHttpRequest) {
348
+ var req = new XMLHttpRequest();
349
+ // some versions of Moz do not support the readyState property and the onreadystate event so we patch it!
350
+ if (req.readyState == null) {
351
+ req.readyState = 1;
352
+ req.addEventListener("load",
353
+ function() {
354
+ req.readyState = 4;
355
+ if (typeof req.onreadystatechange == "function") {
356
+ req.onreadystatechange();
357
+ }
358
+ },
359
+ false);
360
+ }
361
+ return req;
362
+ }
363
+ if (window.ActiveXObject) {
364
+ return new ActiveXObject(SOAPClient._getXmlHttpProgID());
365
+ }
366
+ }
367
+ catch (ex) {
368
+ }
369
+ throw new Error("Your browser does not support XmlHttp objects");
370
+ };
371
+ SOAPClient._getXmlHttpProgID = function() {
372
+ if (SOAPClient._getXmlHttpProgID.progid) {
373
+ return SOAPClient._getXmlHttpProgID.progid;
374
+ }
375
+ var progids = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
376
+ var o;
377
+ for (var i = 0; i < progids.length; i++) {
378
+ try {
379
+ /* eslint no-unused-vars: 0 */
380
+ o = new ActiveXObject(progids[i]);
381
+ return (SOAPClient._getXmlHttpProgID.progid = progids[i]);
382
+ }
383
+ catch (ex) {
384
+ }
385
+ ;
386
+ }
387
+ throw new Error("Could not find an installed XML parser");
388
+ };
396
389
 
397
- SOAPClient._toBase64 = function(input)
398
- {
399
- var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
400
- var output = "";
401
- var chr1, chr2, chr3;
402
- var enc1, enc2, enc3, enc4;
403
- var i = 0;
390
+ SOAPClient._toBase64 = function(input) {
391
+ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
392
+ var output = "";
393
+ var chr1, chr2, chr3;
394
+ var enc1, enc2, enc3, enc4;
395
+ var i = 0;
404
396
 
405
- do {
406
- chr1 = input.charCodeAt(i++);
407
- chr2 = input.charCodeAt(i++);
408
- chr3 = input.charCodeAt(i++);
397
+ do {
398
+ chr1 = input.charCodeAt(i++);
399
+ chr2 = input.charCodeAt(i++);
400
+ chr3 = input.charCodeAt(i++);
409
401
 
410
- enc1 = chr1 >> 2;
411
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
412
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
413
- enc4 = chr3 & 63;
402
+ enc1 = chr1 >> 2;
403
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
404
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
405
+ enc4 = chr3 & 63;
414
406
 
415
- if (isNaN(chr2)) {
416
- enc3 = enc4 = 64;
417
- } else if (isNaN(chr3)) {
418
- enc4 = 64;
419
- }
407
+ if (isNaN(chr2)) {
408
+ enc3 = enc4 = 64;
409
+ }
410
+ else if (isNaN(chr3)) {
411
+ enc4 = 64;
412
+ }
420
413
 
421
- output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
422
- keyStr.charAt(enc3) + keyStr.charAt(enc4);
423
- } while (i < input.length);
414
+ output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
415
+ keyStr.charAt(enc3) + keyStr.charAt(enc4);
416
+ } while (i < input.length);
424
417
 
425
- return output;
426
- }
418
+ return output;
419
+ };