-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
36 lines (20 loc) · 1.73 KB
/
README
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
RemoteProxy
This is a simple CF wrapper for webservice calls. It will provide you with some better availability, caching data as it's requested, which can be used if the service ever goes offline.
This version only supports calls that return queries, but adding support for other types should be trivial.
USAGE:
Take your existing webservice calls:
<cfset wsService = CreateObject('webservice','http://www.myservice.com/') />
And compose them into the proxy instead:
<cfset wsService = CreateObject('component','remoteProxy') />
<cfset wsService.setEndpoint('http://www.myservice.com/') />
Now, the rest of your code should remain the same. When your CF code calls a method on the webservice, the remoteProxy calls it instead, delegating to onMissingMethod(), where the magic happens.
NOTES ON USAGE:
1. You MUST pass your arguments to this component by NAME, in order for onMissingMethod to map them appropriately. Thus, your old call of:
<cfset wsService.getUsersByDept(1,'billing') />
needs to be updated to:
<cfset wsService.getUsersByDept(user_id=1,departmentName='billing') />
2. You must store the component in a shared scope that will persist across requests, ie. APPLICATION or SERVER. This is due to the fact that, internally, the component uses its private VARIABLES to cache method calls:
<cfset APPLICATION.wsService = wsService />
I realize this 2nd point is obvious to experienced CF developers, but may not be so for new folks. Be aware of storing a CFC in a shared scope:
- Changes to the CFC you make won't take affect until you reload the CF server,
- Memory usage will grow as the cache grows, so think through how you utilize this proxy. Build in your own timing mechanisms, or perhaps a way to flush the cache with a ?reload param.