Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issue with cfinvoke and cftry

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
US
i have the following piece of code

<Cftry>
<cfinvoke webservice="#request.WebServiceURL#" timeout="2" method="createNewOrder" Record="#myStruct#" returnvariable="myCUID">
<cfcatch type="any">
<cfif IsDefined('cfcatch.Message')>
<cfset request.myCustomerID = 'null'>
<cfelse>
<cfset request.myCustomerID = myCUID>
</cfif>
</cfcatch>
</cftry>
<cfoutput>#request.myCustomerID#</cfoutput>

this returns an error saying Variable MYCUID is undefined.

if i run this instead

<cfinvoke webservice="#request.WebServiceURL#" timeout="2" method="createNewOrder" Record="#myStruct#" returnvariable="myCUID">
<cfoutput>#myCuID#</cfoutput>

it runs perfectly fine and outputs something like E123456.
why does CF not like surrounding the cfinvoke with cftry. sometimes, the webservice goes down and i want to capture that. if there is a cfcatch.message, i want to set the myCuID to null, otherwise to myCuID. i cannot figure out what i am doing wrong. thanks for the help in advance...


 
interesting but this version works.

<Cftry>
<cfinvoke webservice="#request.WebServiceURL#" timeout="2" method="createNewOrder" Record="#myStruct#" returnvariable="myCUID">
<cfcatch type="any">
<cfset request.myCustomerID = 'null'>

</cfcatch>
</cftry>


<cfif NOT IsDefined('request.myCustomerID')>
<cfset request.arevCustomerID = myCUID>
</cfif>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top