ColdFusion 8 trying to catch a web service error and a problem one should be aware of
Tags: ColdFusion 8, Coldfusion
While writing some code today I ran into a problem that I thought I would share, and I doubt it could be said to be a serious problem, but a problem none the less.
I spend a good deal of time trying to find why a web service was that was failing on instantiation, was not actually being caught by a normal try / catch block.
I would also put this down to a bug in ColdFusion as well.
To give a bit of a background the ColdFusion Application needed to talk to a flax application on another server, the solution that I thought about here was a couple of things. The first thing that I wanted to solve was if the developer was writing the code, and testing the code on either section then it would call a web service locally, or it was in a testing environment or the production server then it would talk to the appropriate server.
The code in question that was a problem to the ColdFusion application was something like this.
I won't go into to much detail about the getUrl(), except to say that its job was to determine where the application was being run from. Due to a change in a requirement for the ColdFusion application, this became a problem for other developers who were not working on the Flex Application but had to work on the ColdFusion Application.
So to get around this I thought that I would just place a try / catch block on this, so that it became something like this.
<cfset local.remoteObject = createObject('webservice', '#getUrl()#/somedir/component') />
<cfcatch type="any">
<cfset local.remoteObject = createObject('webservice' , 'another server location') />
</cfcatch>
</cftry>
It seemed to work well, but to run it through its proper test. I then removed the Flex Application and broke the connection to the RPC, that would have normally have taken place. Except something unexpected happened that shocked me, and left me stumped as to why it was not working.
The problem came down to the fact that the WSDL was no longer a valid location, and would throw an exception regardless of the fact that it was in a try / catch block. Took me awhile to find a solution to this, and get it to work and that was to remove the WSDL cached from the ColdFusion administrator.
But this left me wondering something else, because what I essentially did was make it like the other server had gone down or was just not accessible. And what I found strange was that it would throw a ColdFusion error and not be captured at all, so the question remains is this a bug?
To double check that the I was not seeing things I set up the application to run in the line debugger, and fired a break point on the first instantiation call. I then step over this line, to fine that it dropped straight past all the catch checks and throw an exception straight after it all.
So it left me wondering if I just simulated a call to a server that could potentially go down, why isn't something like this handled by the try / catch block?
There are no comments for this entry.



TweetBacks