Skip to main content
Inspiring
February 26, 2009
Answered

Determine how CFC function was called?

  • February 26, 2009
  • 2 replies
  • 707 views
I have a CFC that can use CFLOCATION under certain conditions. The problem is this function can be called remotely and it will flake out if CFLOCATION is used. Is there some way I can tell within the function if it was called remotely or locally?
This topic has been closed for replies.
Correct answer chazman113
Ah that is what I needed thanks.

2 replies

Inspiring
February 27, 2009
> I have a CFC that can use CFLOCATION under certain conditions.

Your problem is not the "called locally" vs "called as a web service"
thing, it's that you have a CFLOCATION within a CFC method. Redirection on
success or failure (which is what I presume is going on here) should be the
domain of the calling environment, not the method being called. The proof
of this is your very situation: you've now got a method that doesn't work
when called remotely. Quite loosely speaking in the MVC context, you have
a model process doing the work of the controller: it's doing the work *and*
choosing what to do with said work. Those should be two separate bits of
code.

I recommend retasking your code to have the CFLOCATION in the environment
which is working with web pages, and refactor the CFC to provide the
information to make the choice as to redirect or not; which when called as
a web service provides the information to make some other decision not
related to redirection.


However, to answer your actual question: isSoapRequest():
http://livedocs.adobe.com/coldfusion/8/functions_in-k_32.html

--
Adam
chazman113AuthorCorrect answer
Inspiring
February 27, 2009
Ah that is what I needed thanks.
Inspiring
February 26, 2009
Write 3 functions.

Make function 1 available as a web service. Don't allow cflocation.

Make function 2 available only to the cf server. Allow cflocation

Make function 3 available only to your cfc. Include all the code that's required by functions 1 and 2.