1 | 1,129c1,113
|
---|
2 | <
|
---|
3 | <
|
---|
4 | < function loadAsync(sUri, SOAPMessage) {
|
---|
5 | < var xmlHttp = XmlHttp.create();
|
---|
6 | < var async = true;
|
---|
7 | < xmlHttp.open("POST", sUri, async);
|
---|
8 | < xmlHttp.onreadystatechange = function () {
|
---|
9 | < if (xmlHttp.readyState == 4){
|
---|
10 | < var result = xmlHttp.responseText;
|
---|
11 | < getTitle2(xmlHttp.responseXML, xmlHttp.responseText);
|
---|
12 | < }
|
---|
13 | < }
|
---|
14 | < xmlHttp.setRequestHeader("SOAPAction", " ");
|
---|
15 | < xmlHttp.setRequestHeader("Content-Type", "Content-Type: text/xml; charset=utf-8");
|
---|
16 | <
|
---|
17 | < xmlHttp.send(SOAPMessage);
|
---|
18 | < }
|
---|
19 | <
|
---|
20 | <
|
---|
21 | < function messageToSOAP(message) {
|
---|
22 | < soapBody = '<soapenv:Body>' + message + '</soapenv:Body>'
|
---|
23 | < soap = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' + soapBody + '</soapenv:Envelope>'
|
---|
24 | < x= '<?xml version="1.0" encoding="UTF-8"?>' + soap;
|
---|
25 | < return x;
|
---|
26 | < }
|
---|
27 | <
|
---|
28 | <
|
---|
29 | <
|
---|
30 | <
|
---|
31 | < function getText(element) { //get the text from possibly multiple text nodes
|
---|
32 | < if (element.hasChildNodes()) {
|
---|
33 | < tempString = '';
|
---|
34 | < for (j=0; j < element.childNodes.length; j++) {
|
---|
35 | < if (element.childNodes[j].nodeType == Node.TEXT_NODE ) { // =2
|
---|
36 | < tempString += element.childNodes[j].nodeValue;
|
---|
37 | < }
|
---|
38 | < else {
|
---|
39 | < tempString += 'non text node: ';
|
---|
40 | < }
|
---|
41 | < }
|
---|
42 | < return tempString;
|
---|
43 | < }
|
---|
44 | < else {
|
---|
45 | < return 'getText: element has no ChildNodes from which to extract Text';
|
---|
46 | < }
|
---|
47 | < }
|
---|
48 | <
|
---|
49 | <
|
---|
50 | < function newOpenTag(name) {
|
---|
51 | < return '<' + name + '>';
|
---|
52 | < }
|
---|
53 | <
|
---|
54 | < function newCloseTag(name) {
|
---|
55 | < return '</' + name + '>';
|
---|
56 | < }
|
---|
57 | <
|
---|
58 | < function newEmptyTag(name) {
|
---|
59 | < return '<' + name + '/>';
|
---|
60 | < }
|
---|
61 | <
|
---|
62 | < function newElement(name, content) {
|
---|
63 | < e = '<' + name + '>' + content;
|
---|
64 | < e += '</' + name + '>';
|
---|
65 | < return e;
|
---|
66 | < }
|
---|
67 | <
|
---|
68 | <
|
---|
69 | < function newElementAtt1(name, content, attName, attValue) {
|
---|
70 | < e = '<' + name + ' ' + attName + '="' + attValue +'">' + content;
|
---|
71 | < e += '</' + name + '>';
|
---|
72 | < return e;
|
---|
73 | < }
|
---|
74 | <
|
---|
75 | <
|
---|
76 | <
|
---|
77 | <
|
---|
78 | < function newElementAtt(name, content, nameArray, valueArray) {
|
---|
79 | < e = '<' + name + ' ' ;
|
---|
80 | < for (i=0; i < nameArray.length; i++) {
|
---|
81 | < e += newAttribute(nameArray[i], valueArray[i])
|
---|
82 | < }
|
---|
83 | < e += '>' + content;
|
---|
84 | < e += '</' + name + '>';
|
---|
85 | < return e;
|
---|
86 | < }
|
---|
87 | <
|
---|
88 | <
|
---|
89 | < function newAttribute(name, value) {
|
---|
90 | < return ' ' + name + '="' + value + '"';
|
---|
91 | < }
|
---|
92 | <
|
---|
93 | < /*
|
---|
94 | < var a = [];
|
---|
95 | < var b = [];
|
---|
96 | < a[0] = 'title';
|
---|
97 | < b[0] = 'test';
|
---|
98 | < a[1] = 'title2';
|
---|
99 | < b[1] = 'test2';
|
---|
100 | <
|
---|
101 | < alert( newElement('message', 'some content', a=[], b=[]));
|
---|
102 | <
|
---|
103 | < */
|
---|
104 | <
|
---|
105 | < function countElementChildren(node) {
|
---|
106 | < count= 0;
|
---|
107 | < childList = node.childNodes;
|
---|
108 | < for(var i=0; i < (childList.length); i++) {
|
---|
109 | < childNode = childList.item(i);
|
---|
110 | < if ((childNode.nodeType == 1)) { // only count elements
|
---|
111 | < count++;
|
---|
112 | < }
|
---|
113 | < }
|
---|
114 | < return count;
|
---|
115 | < }
|
---|
116 | <
|
---|
117 | < function removeAllChildren(node) {
|
---|
118 | < while (node.hasChildNodes()) {
|
---|
119 | < node.removeChild(node.firstChild);
|
---|
120 | < }
|
---|
121 | < }
|
---|
122 | <
|
---|
123 | <
|
---|
124 | < function isElement(node) {
|
---|
125 | < if (node.nodeType == 1) {
|
---|
126 | < return true; }
|
---|
127 | < else {
|
---|
128 | < return false;
|
---|
129 | < }
|
---|
130 | < }
|
---|
131 | \ No newline at end of file
|
---|
132 | ---
|
---|
133 | > function loadAsync(sUri, SOAPMessage) {
|
---|
134 | > var xmlHttp = XmlHttp.create();
|
---|
135 | > var async = true;
|
---|
136 | > xmlHttp.open("POST", sUri, async);
|
---|
137 | > xmlHttp.onreadystatechange = function () {
|
---|
138 | > if (xmlHttp.readyState == 4) {
|
---|
139 | > var result = xmlHttp.responseText;
|
---|
140 | > getTitle2(xmlHttp.responseXML, xmlHttp.responseText);
|
---|
141 | > }
|
---|
142 | > }
|
---|
143 | > xmlHttp.setRequestHeader("SOAPAction", " ");
|
---|
144 | > xmlHttp.setRequestHeader("Content-Type", "Content-Type: text/xml; charset=utf-8");
|
---|
145 | > xmlHttp.send(SOAPMessage);
|
---|
146 | > }
|
---|
147 | >
|
---|
148 | > function messageToSOAP(message) {
|
---|
149 | > return [
|
---|
150 | > '<?xml version="1.0" encoding="UTF-8"?>',
|
---|
151 | > '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',
|
---|
152 | > '<soapenv:Body>',
|
---|
153 | > message,
|
---|
154 | > '</soapenv:Body>',
|
---|
155 | > '</soapenv:Envelope>'
|
---|
156 | > ].join('');
|
---|
157 | > }
|
---|
158 | >
|
---|
159 | > function getText(element) { // Get the text from possibly multiple text nodes
|
---|
160 | > if (element.hasChildNodes()) {
|
---|
161 | > tempString = [];
|
---|
162 | > // TODO: Remove .length; slow.
|
---|
163 | > for (var i = 0; i < element.childNodes.length; ++i) {
|
---|
164 | > if (element.childNodes[i].nodeType == Node.TEXT_NODE ) { // =2
|
---|
165 | > tempString.push(element.childNodes[i].nodeValue);
|
---|
166 | > } else {
|
---|
167 | > tempString.push('non text node: ');
|
---|
168 | > }
|
---|
169 | > }
|
---|
170 | > return tempString.join('');
|
---|
171 | > } else {
|
---|
172 | > return 'getText: element has no ChildNodes from which to extract Text';
|
---|
173 | > }
|
---|
174 | > }
|
---|
175 | >
|
---|
176 | > function newOpenTag(name) {
|
---|
177 | > return ['<', name, '>'].join('');
|
---|
178 | > }
|
---|
179 | >
|
---|
180 | > function newCloseTag(name) {
|
---|
181 | > return ['</', name, '>'].join('');
|
---|
182 | > }
|
---|
183 | >
|
---|
184 | > function newEmptyTag(name) {
|
---|
185 | > return ['<', name, '/>'].join('');
|
---|
186 | > }
|
---|
187 | >
|
---|
188 | > function newElement(name, content) {
|
---|
189 | > return ['<', name, '>', content, '</', name, '>'].join('');
|
---|
190 | > }
|
---|
191 | >
|
---|
192 | > function newElementAtt1(name, content, attName, attValue) {
|
---|
193 | > return ['<', name, ' ', attName, '="', attValue, '">', content, '</', name,
|
---|
194 | > '>'].join('');
|
---|
195 | > }
|
---|
196 | >
|
---|
197 | > function newElementAtt(name, content, nameArray, valueArray) {
|
---|
198 | > e = ['<', name, ' '];
|
---|
199 | > // TODO: Remove .length; slow.
|
---|
200 | > for (var i = 0; i < nameArray.length; ++i) {
|
---|
201 | > e.push(newAttribute(nameArray[i], valueArray[i]));
|
---|
202 | > }
|
---|
203 | > e.push('>', content, '</', name, '>';
|
---|
204 | > return e.join('');
|
---|
205 | > }
|
---|
206 | >
|
---|
207 | >
|
---|
208 | > function newAttribute(name, value) {
|
---|
209 | > return [' ', name, '="', value, '"'].join('');
|
---|
210 | > }
|
---|
211 | >
|
---|
212 | > // Tests?
|
---|
213 | > /*
|
---|
214 | > var a = [];
|
---|
215 | > var b = [];
|
---|
216 | > a[0] = 'title';
|
---|
217 | > b[0] = 'test';
|
---|
218 | > a[1] = 'title2';
|
---|
219 | > b[1] = 'test2';
|
---|
220 | >
|
---|
221 | > alert(newElement('message', 'some content', a=[], b=[]));
|
---|
222 | > */
|
---|
223 | >
|
---|
224 | > function countElementChildren(node) {
|
---|
225 | > count = 0;
|
---|
226 | > childList = node.childNodes;
|
---|
227 | > // TODO: Remove .length; slow.
|
---|
228 | > for (var i = 0; i < childList.length; ++i) {
|
---|
229 | > childNode = childList.item(i);
|
---|
230 | > if (childNode.nodeType == 1) { // Only count elements
|
---|
231 | > ++count;
|
---|
232 | > }
|
---|
233 | > }
|
---|
234 | > return count;
|
---|
235 | > }
|
---|
236 | >
|
---|
237 | > function removeAllChildren(node) {
|
---|
238 | > while (node.hasChildNodes()) {
|
---|
239 | > node.removeChild(node.firstChild);
|
---|
240 | > }
|
---|
241 | > }
|
---|
242 | >
|
---|
243 | > function isElement(node) {
|
---|
244 | > return node.nodeType == 1;
|
---|
245 | > }
|
---|