ArrayNew and cfinvoke
Hello Everyone,
I am working on a small tool and I want to invoke another
function from within another function while passing an array to the
function being called.
I create the the array:
<cfset zones = ArrayNew(1)>
<cfset ArrayAppend(zones, #get_options.z0#)>
<cfset ArrayAppend(zones, #get_options.z1#)>
<cfset ArrayAppend(zones, #get_options.z2#)>
<cfset ArrayAppend(zones, #get_options.z3#)>
<cfset ArrayAppend(zones, #get_options.z4#)>
<cfset ArrayAppend(zones, #get_options.z5#)>
I then invoke the function:
<cfinvoke component="admin_mc" method="zone_calc"
argumentcollection="#zones#" returnvariable="zone_whole">
when I go to the function I get this error:
You have attempted to dereference a scalar variable of type
class coldfusion.runtime.Array as a structure with members.
292 : <cfinvoke component="admin_mc" method="zone_calc"
argumentcollection="#zones#" returnvariable="zone_whole">
Any ideas?
using CF8
Greatly apreciated
thank you
Luc
incorrect use of argumentcollection attribute - it requires a
STRUCTURE
of arguments, while you are passing it an array.
if you just need to pass your array as an argument to your
function, you
should be doing something like
<cfinvoke component="admin_mc" method="zone_calc"
yourcfargumentname="#zones#" returnvariable="zone_whole">
or use <cfinvokeargument ...> tag
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Similar Messages
-
Web Services and Parameters - Problem
I have 2 web services I set up. One takes no parameters and
works fine. The
other takes arguments and it tells me the method cannot be
found. What am I
missing? What is the magic bullet to invoke a web service
that takes
arguments and have it work? I have all the web service's
arguments set to
'required="yes"' and I set up another 'no argument function'
in the
SearchProperty.cfc to make sure it also works and it did
fine, so I know the
web service exists and is accessible.
I tried both createObject in my contoller and cfinvoke. Both
work fine for
the web service that takes no arguments and neither work for
the one that
does.
Here is my controller blocks (please excuse the Model-Glue)
This works fine
<!---Get All Cities For Search Engine--->
<cffunction name="getCities" access="public"
returntype="void"
output="false" hint="I displays all the cities for the front
page">
<cfargument name="event" type="ModelGlue.Core.Event"
required="yes">
<cfset Cities = createObject("webservice",
http://74.86.90.210/realitorToolBox/model/webservices/CityGateway.cfc?wsdl")/>
<cfset allCities = Cities.getCities() />
<cfset arguments.event.setValue("getAllCities",
allCities)/>
</cffunction>
This cannot be found:
<!---Search Residentual Properties--->
<cffunction name="SearchProperties" access="public"
returntype="void"
output="false" hint="I displays all the cities for the front
page">
<cfargument name="event" type="ModelGlue.Core.Event"
required="yes">
<cfset userID = 555555>
<cfset bedrooms =
arguments.event.getValue("bedrooms")/>
<cfset bathrooms =
arguments.event.getValue("bathrooms")/>
<cfset footage = arguments.event.getValue("footage")/>
<cfset minprice =
arguments.event.getValue("minprice")/>
<cfset maxprice =
arguments.event.getValue("maxprice")/>
<cfset basement =
arguments.event.getValue("basement")/>
<cfset garage = arguments.event.getValue("garage")/>
<cfset CITIES = arguments.event.getValue("CITIES")/>
<cfset Search = createObject("webservice",
http://74.86.90.210/realitorToolBox/model/webservices/SearchProperty.cfc?wsdl")/>
<cfset searchAll = Search.SearchProperty(#userID#,
#bedrooms#,
#bathrooms#, #footage#, #minprice#, #maxprice#, #basement#,
#garage#,
#CITIES#) />
<cfset arguments.event.setValue("Results",
searchAll)/>
</cffunction>
Any ideas? My client is getting anxious and I hope to offer
this service to
other developers to use for their client's site.Ok, I will make this simplier. Couple questions.
Is it possible to use cfargument in a web service?
I looked at the samples out there and they all just have
queries that take a
form variable (#form.name#) since it was being passed by a
form.
Is it possible to have one web service function invoke
another function in
the same cfc?
If you have one function that calls another to first validate
the user and
then invoke another to get the search results, do all have to
be remote or
can you have the search be private since you dont want it
invoked remotely.
I.E.
<cffunction name="search" access="remote"
returntype="query">
<cfset authenticate = authenticateUser(#username#)>
<cfif authenticate EQ 'yes'>
<cfset myResults = searchProperty(#mlsnumber#)>
</cfif>
<cfreturn my Results>
</cffunction>
I tried a simple city search and tried to pass a variable
argument.
<cfinvoke
webservice="
http://74.86.90.210/realitorToolBox/model/webservices/CityGateway.cfc?wsdl"
method="findCity" city = "clinton" returnvariable="aQuery"/>to:
<cffunction name="findCity" access="remote"
returntype="query"> <cfquery name="getCities"
datasource="MLSListings"> Select city FROM residential WHERE
city = '#city#' </cfquery> <cfreturn getCities>
</cffunction>And I still get a function cannot be found, even
though I used the cfcexplorer to verify that it does exist on the
remote server.Any ideas? -
I'll try to make this as simple as possible in hope I get a
response. I have a particular web service I need to consume. Using
its WSDL file I have locally, how can I make a direct SOAP call to
it using the actual XML SOAP envelope? It balks when trying to use
cfinvoke with CFinvokearguments, giving me a "method doesn't exit"
error. I figure I can invoke the service somehow using CFHTTP and
using the entire soap envelope to call the web service. Am I
barking up the wrong tree here?
Looking at the actual soap body inside the envelope, Since
its XML there are a number of child tags inside i.e.
<soapenv:Body>
<the_request>
<security_header>
<some_element>whatever</some_element>
<another_element>whatever2</another_element>
</security_header>
<config_header>
<some_configelement>whatever</some_configelement>
<another_configelement>whatever2</another_configelement>
</config_header>
<data>
<some_dataelement>whatever</some_dataelement>
<another_dataelement>whatever2</another_dataelement>
</data>
</the_request>
</soapenv:body>
Thats it, no magic, no soap headers, nothing. Its all
contained within the body. Side note: How does CFinvoke arguments
keep track of what child elements they are under in the call? Any
help would be appreciated..
Thanks! JeffI wish I could give more details. Heck, I would post the
entire WSDL and soap call, but I am under NDA with the company that
I am implementing it from. I am also in between a rock and hard
place, because they DO NOT have any coldfusion implementation of
their product and know nothing about the language. So, I am SOL
when I am having problems with consuming their web service.
With that being said, I have used CFINVOKE and CFinvoke
arguement. Odd thing is that when I do and pass the correct
arguments, it tells me that the method doesn't exist. Now, I have
even heard that you must include all optional arguments with some
web services. I tried that too, still it tells me the method I
chose doesn't exist. Very frustrating.
Thats why I thought there might be a way to use the entire
soap envelope against the WSDL to produce a result other than
"method doesn't exist".
Jeff -
I am getting a bit confused with cfcs using cfreturn and
cfinvoke please be patient!
1.Setting variables in cfc
In this example cfc I make a query. The cfreturn tag does
<cfreturn expression /> as I understand it. I don´t
understand how you define the expression - can you return
arguments, any column I like in variables? How do I do that?
<cfcomponent><cffunction><cfargument
name="user">
<cfquery name="checkuser">
select col1, col2, col3, col4, col5, col6
from user
where .....=....
</cfquery>
<cfreturn checkuser.col1>
2. Calling cfc:
In cfinvoke you call a variable using returnvariable="". Is
it true that the variable doesn´t have to have the same name
as in the method that the cfinvoke tag is calling? What does return
variable call? How do I define what it calls?In any cffunction, inside or outside a cfc, if you are going
to return a value, you use the cfreturn tag. You can return
constants like true, 1, "Dan is so smart", or variables. What you
return has to be consistent with the returntype attribute of your
cffunction tag.
When you invoke a variable, you can use any name you want as
the return variable. In theory, you don't even know any variable
names inside the function. The return variable does not call
anything. It accepts what the function returns.
It is the cfinvoke tag that calls something. You control what
it calls with it's attributes.
Further details are in the cfml reference manual. -
Please help!!! This expression must have a constant value
I try to work with cfc and cfinvoke and not sure why I got this error. Searched
in google for answer but still don't get any. Can anyone help please...not sure where
I had it wrong...I thought my codes should work (?)
When a form is submitted I have this codes in formaction.cfm, I captured all the form fields in a structure:
<CFSET st_Registration = {Salutation="#Trim(Form.Salutation)#", FName = "#Trim(Form.FName)#", MName = "#Trim(Form.Mname)#",LName = "#Trim(Form.LName)#" .......etc }/>
Then I set all the required fields:
<CFSET ReqFields ="Salutation,FName,LName,Addr1,City,State,Zip,Country,Phone,Email,username,password">
<!--- Then send the structure and req. fiels list to a function located in a component to verify required fields ---><cfset CreateUserInfo = createObject("component", "airbucks.cfcomp.VerifyInput").init()>
<CFINVOKE component="#CreateUserInfo#" method="Verify_ReqFields" st_Registration = "#st_Registration#" RequiredFields ="#ReqFields#" returnvariable="VerifyResult">
<CFIF #VerifyResult# IS "">
<cfdump var="#st_Registration#">
<CFELSE>
<CFIF #st_Registration["Country"]# IS "USA">
<CFINCLUDE template="registration_ret.cfm">
<CFELSE>
<CFINCLUDE template="registration_other_ret.cfm">
</CFIF>
</CFIF>
<!--- Below is part of the component with the function for checking required fields --->
<cfcomponent displayname="VerifyInputData" output="false"> <CFFUNCTION name="Init" access="public" returntype="any" output="false" hint="Returns an initialized component instance.">
<!--- Return This reference. --->
<cfreturn THIS />
</CFFUNCTION>
<!--- Verify required fields --->
<CFFUNCTION name="Verify_ReqFields">
<cfargument name="st_Registration" type="struct" required="true">
<cfargument name="RequiredFields" type="string" required="true">
<!--- check if req. fields are blank --->
<CFSET ErrorList = "">
<cfloop collection="#arguments.st_Registration#" item="KEY">
<CFIF #Trim(st_Registration[KEY])# IS "">
<CFSWITCH expression="#Trim(KEY)#">
<CFCASE value="#arguments.RequiredFields#">
<CFSET ErrorList = ListAppend(ErrorList, "#KEY#")>
</CFCASE>
</CFSWITCH>
</CFIF>
</cfloop>
<CFRETURN ErrorList >
</CFFUNCTION>
</cfcomponent>
Here is the error:
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
This expression must have a constant value.
The error occurred in C:\Inetpub\wwwroot\AirBucks\registrationaction.cfm: line 55
53 :
54 : <!--- Verify required field based on the required list set above --->
55 : <cfset CreateUserInfo = createObject("component", "airbucks.cfcomp.VerifyInput").init()>
56 : <CFINVOKE component="#CreateUserInfo#" method="Verify_ReqFields" st_Registration = "#st_Registration#" RequiredFields ="#ReqFields#" returnvariable="VerifyResult">
57 :Thank you and I'll change my codes.
When I did the following, I still get the same error.
Isn't it CreateUserInfo is the object?
<cfset CreateUserInfo = createObject("component", "airbucks.cfcomp.VerifyInput").init()>
<CFSET VerifyResult = CreateUserInfo.Verify_ReqFields(st_Registration, ReqFields)>
Using cfinvoke used to work.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
This expression must have a constant value.
The error occurred in C:\Inetpub\wwwroot\AirBucks\registrationaction.cfm: line 54
52 : <!--- Verify required field based on the required list set above --->
53 :
54 : <cfset CreateUserInfo = createObject("component", "airbucks.cfcomp.VerifyInput").init()>
55 : <!---
56 : <CFINVOKE component="#CreateUserInfo#" method="Verify_ReqFields" st_Registration -
Complex datatypes - WebServices/APIs
I'm attempting to learn how to manage Web Services/APIs. I'm using ColdFusion 8 and the webservice is open (no key or password required). With my createobject I don't see where to include the operation or method (see list below) like was done with the <cfinvoke>. With <cfinvoke> I had save the document as wscfc.cfm is it the same with createobject? Thanks for the suggestions TheRealAgentK.
At the bottom of this page is a “Second Attempt” using the Put and <cfinvoke>. This modified code that was sent to me by BKBK (Thanks!). The error message follows the code.
I'm getting an error message (see below). Any help with this API or sample connections would be greatly appreciated.
?WSDL link below:
http://www.spraci.com/services/soap/index.php?wsdl
My script below (operation/method = area_list):
<cfscript>
stUser = structNew();
stUser.appkey = "";
stUser.username = "";
stUser.password = "";
stUser.area = "x0usa";
stUser.name = "";
ws = createObject("webservice", "http://www.spraci.com/services/soap/index.php?wsdl");
myReturnVar = ws.echoStruct(stUser);
</cfscript>
<cfoutput>#myReturnVar#</cfoutput>
Link to API notes:
C:\Users\djones\Documents\Affiliates\spraci\Webmaster Services SPRACI API SOAP area_list.mht
Operations /Methods below?
http://www.xmethods.net/ve2/WSDLAnalyzer.po;jsessionid=GuNmIhBRDeHT2vRN_L4c7nK8
area_list
area_getinfo
event_list
event_getinfo
event_show
event_add
event_update
user_getinfo
user_getarea
Error Message Below:
Web service operation echoStruct with parameters {{USERNAME={},PASSWORD={},AREA={x0usa},APPKEY={},NAME={}}} cannot be found.
The error occurred in C:\ColdFusion8\wwwroot\ybah8r\CMS\Progs\eraseme3.cfm: line 17
15 : stUser.name = "";
16 : ws = createObject("webservice", "http://www.spraci.com/services/soap/index.php?wsdl");
17 : myReturnVar = ws.echoStruct(stUser);
18 : </cfscript>
19 :
Second attempt:
<cfset AreaFetch = createobject("java","java.util.Hashtable")>
<cfscript>
AreaFetch.put("appkey", "");
AreaFetch.put("username", "");
AreaFetch.put("password", "");
AreaFetch.put("area", "x0usa");
AreaFetch.put("name", "");
</cfscript>
<cfinvoke
webservice = "http://www.spraci.com/services/soap/index.php?wsdl"
method="area_list"
inputStructArray ="#AreaFetch#"
returnvariable="foo"
>
<cfdump var="#foo#">
Error message:
Web service parameter name data cannot be found in the provided parameters {INPUTSTRUCTARRAY}.
The error occurred in C:\ColdFusion8\wwwroot\ybah8r\wscfc.cfm: line 41
39 : webservice = "http://www.spraci.com/services/soap/index.php?wsdl"
40 : method="area_list"
41 : inputStructArray ="#AreaFetch#"
42 : returnvariable="foo"
43 : >Hi,
Did you solve this one?
I'm having the exact same problem, trying to communicate with Oracle Wireless webservices from htmldb,
which kind of made me dissapointed because they are both Oracle products! Basically what wireless wants is an array input and htmldb complains about this!
Any solutions?
Magnus -
I am trying to use the generateReportSQL(), executeXMLQuery through WSDL. I am able to get the report to run, however, I am unable to apply any "filterExpressions" to it. Any help on getting this to work would be greatly appreciated!!
XML variations for filterExpressions that I tried but they were all completely ignored:
1. <?xml version="1.0" encoding="utf-8"?><saw:filter xmlns:saw="com.siebel.analytics.web/report/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1"><sawx:expr xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr></saw:filter>
2. <saw:filter xmlns:saw="com.siebel.analytics.web/report/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1"><sawx:expr xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr></saw:filter>
3. <?xml version="1.0" encoding="utf-8"?><saw:filter subjectArea="Security Hub" xmlns:saw="com.siebel.analytics.web/report/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1"><sawx:expr xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr></saw:filter>
4. <saw:filter subjectArea="Security Hub" xmlns:saw="com.siebel.analytics.web/report/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1"><sawx:expr xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr></saw:filter>
5. <sawx:expr xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1" xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr>
6. <sawx:expr subjectArea="Security Hub" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1" xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr>
7. <?xml version="1.0" encoding="utf-8"?><sawx:expr subjectArea="Security Hub" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="200705140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawx="com.siebel.analytics.web/expression/v1" xsi:type="sawx:comparison" op="equal"><sawx:expr xsi:type="sawx:sqlExpression">User.Center</sawx:expr><sawx:expr xsi:type="xsd:string">000000</sawx:expr></sawx:expr>I wish I could give more details. Heck, I would post the
entire WSDL and soap call, but I am under NDA with the company that
I am implementing it from. I am also in between a rock and hard
place, because they DO NOT have any coldfusion implementation of
their product and know nothing about the language. So, I am SOL
when I am having problems with consuming their web service.
With that being said, I have used CFINVOKE and CFinvoke
arguement. Odd thing is that when I do and pass the correct
arguments, it tells me that the method doesn't exist. Now, I have
even heard that you must include all optional arguments with some
web services. I tried that too, still it tells me the method I
chose doesn't exist. Very frustrating.
Thats why I thought there might be a way to use the entire
soap envelope against the WSDL to produce a result other than
"method doesn't exist".
Jeff -
I'm using ColdFusion 8. I need help with Web Services and APIs. I can get the simple a convernsion from Celsius to Fahrenheit to work:
<cfinvoke
webservice = "http://webservices.daehosting.com/services/TemperatureConversions.wso?WSDL"
method="CelciusToFahrenheit"
nCelcius = "54"
returnvariable="foo"
>
<cfoutput>#foo#</cfoutput>
I can't get anything else to run. Is there a standard template, tool of dvelopment style that I can use to fill in information? Bellow is an API link for SPRACI, it is open an does not require an API key. Can some show me how to intergrate the functions into a web page. Or provide me with other examples that I can study? Thanks
Site with the SPRACI API:
http://www.spraci.com
http://www.xmethods.net/ve2/ViewListing.po;jsessionid=kDmNk9mBY6I2x7C9VJMbvmEl?key=uuid:85 9FF87B-E535-4B29-4E16-ADEC0589B599
http://www.spraci.com/services/soap/index.php?wsdl
Operation / Method Name
area_list
area_getinfo
event_list
event_getinfo
event_show
event_add
event_update
user_getinfo
user_getareaI'm attempting to learn how to manage Web Services/APIs. I'm using ColdFusion 8 and the webservice is open (no key or password required). With my createobject I don't see where to include the operation or method (see list below) like was done with the <cfinvoke>. With <cfinvoke> I had save the document as wscfc.cfm is it the same with createobject? Thanks for the suggestions TheRealAgentK.
At the bottom of this page is a “Second Attempt” using the Put and <cfinvoke>. This modified code that was sent to me by BKBK (Thanks!). The error message follows the code.
I'm getting an error message (see below). Any help with this API or sample connections would be greatly appreciated.
?WSDL link below:
http://www.spraci.com/services/soap/index.php?wsdl
My script below (operation/method = area_list):
<cfscript>
stUser = structNew();
stUser.appkey = "";
stUser.username = "";
stUser.password = "";
stUser.area = "x0usa";
stUser.name = "";
ws = createObject("webservice", "http://www.spraci.com/services/soap/index.php?wsdl");
myReturnVar = ws.echoStruct(stUser);
</cfscript>
<cfoutput>#myReturnVar#</cfoutput>
Link to API notes:
C:\Users\djones\Documents\Affiliates\spraci\Webmaster Services SPRACI API SOAP area_list.mht
Operations /Methods below?
http://www.xmethods.net/ve2/WSDLAnalyzer.po;jsessionid=GuNmIhBRDeHT2vRN_L4c7nK8
area_list
area_getinfo
event_list
event_getinfo
event_show
event_add
event_update
user_getinfo
user_getarea
Error Message Below:
Web service operation echoStruct with parameters {{USERNAME={},PASSWORD={},AREA={x0usa},APPKEY={},NAME={}}} cannot be found.
The error occurred in C:\ColdFusion8\wwwroot\ybah8r\CMS\Progs\eraseme3.cfm: line 17
15 : stUser.name = "";
16 : ws = createObject("webservice", "http://www.spraci.com/services/soap/index.php?wsdl");
17 : myReturnVar = ws.echoStruct(stUser);
18 : </cfscript>
19 :
Second attempt:
<cfset AreaFetch = createobject("java","java.util.Hashtable")>
<cfscript>
AreaFetch.put("appkey", "");
AreaFetch.put("username", "");
AreaFetch.put("password", "");
AreaFetch.put("area", "x0usa");
AreaFetch.put("name", "");
</cfscript>
<cfinvoke
webservice = "http://www.spraci.com/services/soap/index.php?wsdl"
method="area_list"
inputStructArray ="#AreaFetch#"
returnvariable="foo"
>
<cfdump var="#foo#">
Error message:
Web service parameter name data cannot be found in the provided parameters {INPUTSTRUCTARRAY}.
The error occurred in C:\ColdFusion8\wwwroot\ybah8r\wscfc.cfm: line 41
39 : webservice = "http://www.spraci.com/services/soap/index.php?wsdl"
40 : method="area_list"
41 : inputStructArray ="#AreaFetch#"
42 : returnvariable="foo"
43 : > -
How not to use Cold Fusion and Java
Overview
This write up is intended to give java developers that are
developing ColdFusion applications some beneficial information:
things that are not documented.
Scenario
The company builds enterprise class web application software
for fortune 500 companies. It had purchased a CF 7 based product,
had and existing proprietary J2EE based product, and needed to
integrate the two while meeting a host of new requirements. These
requirements were based on delivering a better user experience,
faster / cheaper integration, increased flexibility /
configuration, useablily, decreasing maintenance costs, the ability
to deploy in either install or ASP models. An initiative was
started to create a new framework that integrated the best of each
technologies. Tactically, this meant that we were to build a hybrid
CF and java application: one that used building blocks (decoupled /
cohesive components) that would allow applications to be rapidly
assembled, configured and deployed. This made sense on several
levels, the team was composed of Java and CF developers, the CF
rapid application development was very productive, there is great
functionality delivered in the CF platform and initial performance
tests showed no cause for alarm
The agreed upon design, based on requirements, and analysis
by both the CF and Java staff has us using CF in the presentation
layer, using a CF based MVC, use of CF based web services. The MVC
was deployed using CFC inheritance for model objects and views made
use of CF custom tags. The internals of the application, used a
rules engine, some proprietary java, ORM, and other J2EE
technology. The initial performance of the system was reasonable.
We pushed on with product implementation.
Then it was time to load test the application, and tune it.
Under load the response times were orders of magnitude slower,
sometimes the pages even timed out.
Armed with our profiler, oracle execution plans and we
charged ahead addressing issue after issue. Note that we took
meticulous care in tweaking the active thread pool and ensuring
that our CF setup was tuned for our application. None of the
observations here are a condemnation of the language; rather they
are aspects that, when considered together, not conducive for
building integrated java and CF frameworks that use a structured /
OO programming practices. Further detail can be provided on
request.
CFC inheritance should be avoided - resolution of variable
scope is expensive even if properly declared.
Since CF creates a class per method under the covers call
stacks become very large, especially if used in a loop. This is
nominally exacerbated by CF calls necessary to set up for the
method call (String.toUpper()).
Nesting of loops and if statements should be kept to a
minimum - the conditional for each lookup of logical operator like
LT, GT are synchronized. Under load this results in thread waits.
Jrun has as single thread pool - both http and web service
requests use the same pool. Under load this leads to thread
deadlock. There are work arounds, but they are painful.
Recursion should be avoided - we had a few recursive routines
and these had to be rewritten.
Custom Tags - should be used sparingly - each custom tag
makes a synchronized call to the license server - (This may be
fixed in CF 8)
Summary
In the end we got the performance to reasonable numbers, but
we ended up moving some code to java (Custom Tags) and getting rid
of 'good programming' practices (Inheritance, loops, etc), mandated
proper variable scoping for those things left over. We prototyped a
sans cold fusion implementation and had an order of magnitude
improvement in performance and number of requests served per
second.
The lesson? Use Coldfusion in its sweet spot: make a query,
iterate over the results and format for display. Extensive use of
structure programming techniques or OO CFCs should be avoided: they
will work but under load - but are better as a prototype. Building
frameworks in CF? Think twice, no three times, and, if you must, be
minimalist.
Textinteresting aslbert123,
Not that I doubt you, but could you answer some questions
about your implementation that was so slow:
1.) Did you put your CFCs in the application or server scope?
2.) Were you initializing your CFCs, via CreateObject or
<cfinvoke>, on every request?
3.) Are you sure that you were properly Var'ing every
variable in your methods? (people typically forget about query
names and loop iterator variables)
4.) Could you give examples of how your inheritence was set
up?
5.) For CustomTags, did you call them the old <cf_tag>
way or the newer, better-performing <cfimport> way?
6.) How did you connect CF to Java exactly?
Thanks,
Aaron -
Consuming a webservice and attributes
I'm trying to noodle my way thru consuming a webservice and
it is not making sense when I'm trying to get attributes from a
webservice. Can someone point me in the right direction. I've
included what the xml output looks like and my cfinvoke and a
cfdump of the invoke return variable. I just don't know how to
bring back that array of course ids??
The service returns course ids
<?xml version="1.0" encoding="utf-8" ?>
- <Courses>
<Course CourseID="1167" CourseName="Human Performance
Tools - Self Checking" />
<Course CourseID="1168" CourseName="Human Perfomance
Tools - 3 Way Communication" />
<Course CourseID="1169" CourseName="Human Performance
Tools - Phonetic Alphabet" />
<Course CourseID="1170" CourseName="Human Performance
Tools - Pre-Job Briefing" />
<Course CourseID="1171" CourseName="Initial Plant Access
Training" PadsCode="PAT034" />
<Course CourseID="1172" CourseName="Initial Radiation
Worker Training" PadsCode="RWT" />
<Course CourseID="1224" CourseName="Plant Access Requal
Training" PadsCode="PAT034" />
<Course CourseID="1225" CourseName="RWT Requal Training"
PadsCode="RWQ" />
<Course CourseID="1226" CourseName="Proctoring
Responsibilities" />
<Course CourseID="1235" CourseName="Generic Confined
Space" />
<Course CourseID="1236" CourseName="Generic Fall
Protection" />
</Courses>
object of
org.tempuri.LMSWebSvc.LMS_Interface.GetCoursesResponseGetCoursesResult
Methods hashCode (returns int)
equals (returns boolean)
getSerializer (returns interface
org.apache.axis.encoding.Serializer)
getDeserializer (returns interface
org.apache.axis.encoding.Deserializer)
getTypeDesc (returns org.apache.axis.description.TypeDesc)
get_any (returns [Lorg.apache.axis.message.MessageElement;)
set_any (returns void)
getClass (returns java.lang.Class)
wait (returns void)
wait (returns void)
wait (returns void)
notify (returns void)
notifyAll (returns void)
toString (returns java.lang.String)I found a way to get the soap request into an xml document.
It was not intuitive to me but works.
Basically rereading this post:
http://www.houseoffusion.com/cf_lists/messages.cfm/forumid:4/threadid:44797#233359
gave me more insight. The tostring function appears to allow me to
get the raw xml that CF is struggling to noodle out. -
Web Services and Nested Complex Types
I am having troubles trying to get coldfusion to use a web
service function.
I know that the web service works as I am sending another
function in a simple variable and receiving a simple variable. I
know the function exists as I when I dump the object the function
is there and I have been told by who supplies it that it works in
other languages.
The problem I am having is that when I call the function I
get the following error: Web service operation "[function name]"
with parameters [parameters] could not be found. I am lead to
believe that it may have to do with the fact that one of the
parameters is a complex type with nested complex types, because of
the amount of trouble it took to get nested complex types to
(apparently) work.
Has anyone had this problem before and/or know how to fix
it?You can invoke methods which take complextypes as parameters.
The idea is to create first a structure which represents the
complextype. For example; crit = structNew(), crit.paramname1 =
value1, ctir.paramname2 = value2. After this, you just pass the
structure
crit as a parameter value, for example with
<cfinvokeargument>.
Always check the wsdl and the possible documentation
carefully. You'll get always an error if the types of the
parameters passed didn't match exactly to what was expected.
Handling complextype responses is also possible, but not very
elegant with ColdFusion.
For example, you have <cfinvoke
returnvariable="wsResult"... >, and you get a java object as a
response which you can really do nothing about with CF functions,
you must use Java Reflection API to extract the values.
<cfset oFields =
wsresult.getClass().getDeclaredFields()>
<cfoutput>
<cfloop from="1" to="#arraylen(oFields)#" index="fi">
<cfset field = oFields[fi].getName()>
<cfif isdefined("wsresult." & field) AND field NEQ
"typedesc">
#field# = #wsResult[field]#<br>
</cfif>
</cfloop>
</cfoutput>
The above is just an example, and It might work with only
some types of complextype responses. But it's a start. :)
http://www.mail-archive.com/[email protected]/msg00553.html
is also another example about handling complextype responses. It
plays "safer", not relying that CF can extract values without
"getters" automatically, and is more of a complete solution. -
I ran into a really odd behavior using cfinvoke in CF9. This came up for an application that has run fine on earlier version of CF and then broke on CF9.
The basic error comes up when we do something like (not actual code, but what seems to cause the problem):
<cfset stObject = structnew() />
<cfinvoke component="...."
method="get"
returnVariable="stObject" />
In this case where stObject is defined prior to running the cfinvoke, the get() method won't populate stObject.
However, if we do the same thing using the following:
<cfset stObject = createObject(....).get() />
then stObject is properly populated.
To make the older application work, we've had to go through the code and rewrite the cfinvoke's into CreateObject(...).method(). That gets past the errors but doesn't make any sense.
Has anyone else seen anything like this?
dI have not experienced this, no. However I have to say I very seldom use <cfinvoke>.
Can you contrive a stand-alone / simple reproduction case of this?
Adam -
Using CreateObject for Webservice with username and password
When using createObject() to call a web service how do I pass
in the user name and password required by the service?
If I do a cfdump on the webservice object I see it has
setUserName() and setPassword() methods but they don't seem to be
working.
I also see there are properties named "USERNAME_PROPERTY" and
"PASSWORD_PROPERTY" but I can't seem to modify them in code. I
suppose they are protected.
example:
ws = createObject("webservice", "
http://url.to/wsdl.xml",
"serviceport");
ws.setUserName("myawesomeusername");
ws.setPassword("myawesomepassword");
myReturn = ws.serviceMethodCall("bla");quote:
Originally posted by:
MACRStockHolder
For anyone that encounters the same issue/question;
apparently you can't apply a username/password to the object call
like you can when using <cfinvoke> to make a web service
call.
FYI Adobe: this is VERY limiting, I have to use a web service
that uses in/out parameters which to the best of my knowledge
requires the use of createObject() but at the same time the web
service requires a username and password which I can only do with
<cfinvoke>. Looks like I will be writing a compiled custom
tag just for a workaround.
According to the docs you can provide a username and password
by passing a struct containing these items to CreateObject
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_18.html#45 14398
If you like cfinvoke use it. You can get return values by
using the returnVariable argument. I would assume mutliple output
parameters would be returned in a struct.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_i_10.html#4001127 -
I have a date array that i created from a database. I am trying to sort the dates into the correct order with the upcoming on top.... the best would be that after the date has passed it would go to the bottom of the list. Can anyone tell me if I am on the right path with what I have so far and give me any hints? thanks (the second loop give me an error)
<!--- Declare query array --->
<cfset dateArray = arraynew(1)>
<!--Poppulate Array row by row--->
<cfloop query="CDE_Dates2">
<cfset dateArray[currentRow][1] = event_date>
</cfloop>
<!--- Sort Array Dates --->
<cfloop index="i" from="1" to="#arrayLen(dateArray)#">
<cfset dateVar = DateFormat(dateArray[i],"YYYY/MM/DD")>
</cfloop>I think I read that as you want dates sored in an order something like this: future dates at the top, sorted in ascending order (most imminent first to farthest future last), then past dates at the bottom in ascending order (oldest first to most recent past last).
The easiest way would be to either do this when you query the database (in your CDE_Dates2) or do a query-of-query on CDE_Dates2. You can do it using a union and adding an extra column for sorting. Here's some SQL pseudo-code:
SELECT dateColumn, otherColumn, anotherColumn, 0 AS sortOverride
FROM someTable
WHERE dateColumn > <cfqueryparam value="#Now()#" cfsqltype="cf_sql_date">
UNION
SELECT dateColumn, otherColumn, anotherColumn, 1 AS sortOverride
FROM someTable
WHERE dateColumn <= <cfqueryparam value="#Now()#" cfsqltype="cf_sql_date">
ORDER BY sortOverride, dateColumn
This will force the future dates to the top and put past dates at the bottom.
You could do the same thing in a QofQ.
-Carl V. -
Don't understand cffunction and cfcomponent
I am trying to alter Forta's ajax related select tutorial to fit my needs. I am having trouble understanding the details of this .cfc though.
<cfcomponent output="false">
<!--- Get array of media types --->
<cffunction name="get_states" access="remote" returnType="array">
<cfset data="">
<cfset result=ArrayNew(2)>
<cfset i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,states
FROM state
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.state[i]>
</cfloop>
<cfreturn result>
</cffunction>
<!--- Get art by media type --->
<cffunction name="get_waters" access="remote" returnType="array">
<cfargument name="location" type="string" required="true" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,name
FROM waters
WHERE bow_state = '#arguments.location#'
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>
When I put '#arguments.id#' into the second query, I get results. However, I'd like to query by the name instead, so I am trying location. I don't fully understand so I am hacking around with this a bit but I'd like to 1 - get results by name instead of id and 2 - understand the arguments variable so I really know what is going on.
Thanks!Sorry, didn't see this before I posted.
But I think my suggestion was in keeping with the example. If you need to select on "state", then make the "state" column of your first query to be the first value in the array that you return:
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,states
FROM state
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.state[i]>
<cfset result[i][2]=data.state[i]>
</cfloop>
This will make your select look something like this in the rendered HTML:
<select id="states" name="whatever...">
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
</select>
So then, on your second, dependent select, you'd specify the binding like so (just like you did, really):
<cfselect name="waters" bind="cfc:_ffc_cfc_select_jump.get_waters({states})" bindonload="false"></cfselect>
However, now, because the value of the "states" select options are state names, rather than ids, you should now be able to use the argument in your query based on state names:
<!--- Get art by media type --->
<cffunction name="get_waters" access="remote" returnType="array">
<cfargument name="location" type="string" required="true" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,name
FROM waters
WHERE bow_state = <cfqueryparam value="#arguments.location#" cfsqltype="varchar" /> <!---Be sure to queryparam!!!--->
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
Maybe you are looking for
-
Can I share music library's with different apple ID accounts
I would like to share music library's with my daughter. However, she has a differet User ID then myself. Is this still possible? So far I have set up home sharing and auhorized her computer. I can see and play the music in her library. However, I am
-
Managed Metadata appearing in wrong columns after Restoring a site to a new Site Collection
I've restored a site with some libraries that have Managed Metadata (MM) columns from one site collection into another site collection inside the same web app so it should all subscribe to the same Managed Metadata Service Application. There are two
-
Linked servers:Using 64 and 32 bit ODBC providers concurrently
I have a very odd problem that I hope someone can help me with. I have a 64 bit odbc MySQL driver. Unfortunately, although I can connect to the data source from the control panel, the linked server cannot connect to the MYSQL data source. The funn
-
Lost activation code for PhotoShop CS4 Extended (proof of purchase exists)
I have had had to get Apple to rebuild a computer from the start and all software needs to be reloaded. The only software which has an issue is CS4 as its as the we cannot find the student edition order fulfilment form which was completed and softwar
-
Event Collector versus process chains
In a BW upgrade project from BW 3.1 to BI 7 we have all data load processes in BW managed with old feature "event collector". A very important question : this old feature will continue to manage our data loads in BI 7 or we need obligatorely to