This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
/
CallerService.cfc
118 lines (98 loc) · 2.68 KB
/
CallerService.cfc
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<cfscript>
/*
CallerService.cfc
This ColdFusion component reused by all sample page to get credential information and
it has getNVPResponse method which takes nvpString as parameter and return Nvpresponse
as CF Struct object. using this object we can display the response values
*/
component output="false" {
public string function doHttppost( required struct requestData ) {
var httpService = new http();
httpService.setMethod("post");
httpService.setCharset("utf-8");
httpService.setUrl(requestData.URLBASE);
if (requestData.useProxy is "true")
{
httpService.setProxyServer(requestData.proxyName);
httpService.setProxyPort(requestData.proxyPort);
}
var str = '';
for (key in requestData)
{
httpService.addParam(type="formfield",name="#key#",value="#requestData[key]#",encoded="yes");
str = str & key & '=' & requestData[key] & '&';
}
writeOutput(str);
abort;
var result = httpService.send().getPrefix();
return result.filecontent;
}
public struct function getNVPResponse(required string nvpString) {
var responseStruct = StructNew();
var keyValStruct = StructNew();
var keys = "";
var Values = "";
var nvpArray = ArrayNew(1) ;
var keyArray = ArrayNew(1) ;
var valueArray = ArrayNew(1) ;
var key = "";
var value = "";
var currentValue = "";
var tempVal = "";
var count = 1 ;
var tempvalue = "";
var lennvp = 0;
for (i=1;i LTE len(nvpString);i=i+1)
{
lennvp = lennvp + 1;
var index = 1;
if (#Mid(nvpString, i, 1)# is not "&")
{
tempVal = tempVal & #Mid(nvpString, i, 1)#;
}
if (#Mid(nvpString, i, 1)# is "&" OR "#lennvp#" is "#len(nvpString)#")
{
nvpArray[count] = #trim(tempVal)#;
count = count + 1;
tempVal = "";
}
}
for (i=1;i LTE #ArrayLen(nvpArray)#;i=i+1)
{
currentValue = #nvpArray[i]#;
currentKeyArray = ListToArray(currentValue,'=');
keyArray[i] = currentKeyArray[1];
}
vals = "";
key = "";
for (var i=1;i LT ArrayLen(nvpArray);i=i+1)
{
vals = #nvpArray[i]#;
key = #keyArray[i]#;
value = #RemoveChars(vals ,1, (len(key) +1))#;
valueArray[i] = value;
x = StructInsert(responseStruct,#trim(key)#,#trim(value)#);
}
return responseStruct;
}
public array function populateEmptyValue( required any noteORuid, required any size)
{
if (ArrayIsEmpty(noteORuid) )
{
for (i=1;i LTE size;i=i+1)
{
noteORuid[i] = "";
}
} else {
for (i=1;i LTE size;i=i+1)
{
if (ArrayLen(noteORuid) not equal size)
{
ArrayAppend(noteORuid, "");
}
}
}
return noteORuid;
}
}
</cfscript>