3 Replies Latest reply on Feb 27, 2009 5:41 AM by chazman113

    Determine how CFC function was called?

    chazman113
      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?
        • 1. Re: Determine how CFC function was called?
          Dan Bracuk Level 5
          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.

          • 2. Re: Determine how CFC function was called?
            Level 7
            > 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
            • 3. Re: Determine how CFC function was called?
              chazman113 Level 1
              Ah that is what I needed thanks.