-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestAdapter.htm
77 lines (65 loc) · 3.4 KB
/
TestAdapter.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<title>Test Adapters</title>
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta http-equiv="EXPIRES" content="-1" />
<script type="text/javascript">
function EncodeHtmlChars(str) {
str = str.replace(/&/g, "&");
str = str.replace(/>/g, ">");
str = str.replace(/</g, "<");
str = str.replace(/"/g, """);
str = str.replace(/'/g, "'");
return str;
}
function ExecuteFetchXml(fetchXml) {
var xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" <soap:Header>" +
" <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" +
" <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">Respina</OrganizationName>" +
" <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" +
" </CrmAuthenticationToken>" +
" </soap:Header>" +
" <soap:Body>" +
" <Fetch xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <fetchXml>" + EncodeHtmlChars(fetchXml) + "</fetchXml>" +
" </Fetch>" +
" </soap:Body>" +
"</soap:Envelope>";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
return xmlHttpRequest.responseXML.text;
}
function load() {
var fetchXml =
"<fetch mapping='logical'>" +
" <entity name='account'>" +
" <attribute name='accountid' />" +
" <attribute name='address1_latitude' />" +
" <attribute name='address1_longitude' />" +
" <attribute name='statecode' />" +
" <attribute name='new_popsiteid' />" +
" <attribute name='name' />" +
" </entity>" +
"</fetch>";
var resultXml = ExecuteFetchXml(fetchXml);
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(resultXml);
var accountsNumber = Number(xmlDoc.getElementsByTagName('result').length.valueOf());
for (var i = 0; i < 2; i++) {
var xmlAccount = xmlDoc.getElementsByTagName('result')[i];
document.write(xmlAccount.getElementsByTagName('name')[0].text);
}
}
</script>
</head>
<body onload="load()" style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" >
</body>
</html>