Hi sean,
This is what I'm currently doing on mx 6.1. (Oh ... the humbling shame of posting my crappy code).
<cfargument name="packet" type="string" required="true">
<cfset var cfhttp = 0 />
<cfset var tpResponse = "" />
<cftry>
<cfhttp url="" method="Post" resolveurl="no" timeout="90" throwonerror="yes">
<cfhttpparam name="Content-Type" type="HEADER" value="text/xml" />
<cfhttpparam name="Body" type="BODY" value="#Trim(packet)#" />
</cfhttp>
<cfcatch>
<cfrethrow />
</cfcatch>
</cftry>
<cfset tpResponse = cfhttp.filecontent />
<cfset tpResponse = ReReplace(tpResponse,'<!.*?>', '' ) />
<cfreturn tpResponse >
</cffunction>
</cfcomponent>
From what was said earlier, it would seem that I should replace the call to cfhttp with an invoke call on a container cfc as follows:
<cfargument name="packet" type="string" required="true">
<cfset var cfhttp = 0 />
<cfset var tpResponse = "" />
<cftry>
<cfinvoke component="myCFHTTPCFC" method="doCFHTTP" Servlet=variables.Servlet Packet= arguments.packet returnvariable="tpResponse"/>
<cfcatch>
<cfrethrow />
</cfcatch>
</cftry>
<cfset tpResponse = ReReplace(tpResponse,'<!.*?>', '' ) />
<cfreturn tpResponse >
</cffunction>
</cfcomponent>
<cffunction name="doCFHTTP" aceess="public" returntype="string">
<cfargument name="Servlet" type="string" required="true">
<cfargument name="Packet" type="string" required="true">
<cfhttp url="" method="Post" resolveurl="no" timeout="90" throwonerror="yes">
<cfhttpparam name="Content-Type" type="HEADER" value="text/xml" />
<cfhttpparam name="Body" type="BODY" value="#Trim(arguments.Packet)#" />
</cfhttp>
<cfreturn cfhttp.filecontent />
</cffunction>
</cfcomponent>
----Original Message Follows----
From: Sean Corfield <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: [CFCDev] CFC's and the var scope
Date: Sat, 4 Jun 2005 18:54:33 -0700
On 6/4/05, Peter H <[EMAIL PROTECTED]> wrote:
> I have a cfhttp call inside a cfc method as described and it is called a
> lot. I'm assuming that the named lock could cause performance problems so am
> considering the light-weight container component instead.
Right.
> On this issue, does the <cfinovke> tag handle creation and destrruction of
> the lightweight container component object or do I need to var it make sure
> its created and destroyed with each call.
<cfinvoke> automatically creates the component for you (but you need
to var declare the returnvariable).
Show us your code if you're not sure and we can say yay or nay.
--
Sean A Corfield -- http://corfield.org/
Team Fusebox -- http://fusebox.org/
Got Gmail? -- I have 50, yes 50, invites to give away!
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
