web services and application.cfc

45 views
Skip to first unread message

BarryC

unread,
May 5, 2011, 5:02:57 PM5/5/11
to cfaussie
Hi,

We have an application.cfc at the root of our website, it contains a
function OnRequestEnd() that does some stuff at the end of page
generation, but this seems to get called for our web service files.

I have a web service in a cfc file in a sub-folder within the site,
but in our logs we get error messages when web services are called,
the error is an empty string, but it gives the file and line number
the error is coming from which shows it is our OnRequestEnd() function
when web services are called.

So our structure looks kind of like this;

/webroot/
Application.cfc
/subfolder/
/service/
webservice.cfc

Is there a way to get the web services to ignore or somehow override
the OnRequestEnd() function? I put an Application.cfc file into the
service/ folder and created an empty OnRequestEnd() function but it
seems that the other functions we have in our root Application.cfc no
longer get called either such as OnRequestStart().

We're on Coldfusion 9.

Thanks
Barry

Phil Haeusler

unread,
May 5, 2011, 5:27:28 PM5/5/11
to cfau...@googlegroups.com
Hi Barry

Have your empty Application.cfc extends your base on and then override
OnRequestEnd() with an empty method. That will give you all the other
methods you want.

Or make use of the IsSOAPRequest() function and use it to ignore the
code you are not wanting to run for your web services.

Phil

BarryC

unread,
May 5, 2011, 6:46:54 PM5/5/11
to cfaussie
excellent I never thought of doing that, thanks, I'll have a go and
see if it works out. :)

BarryC

unread,
May 5, 2011, 9:35:12 PM5/5/11
to cfaussie
hmmm, It would be ideal to check within our Application.cfc if the
request is a SOAP request, but using IsSOAPRequest() inside
application.cfc doesn't work, it always returns false. Is there a way
to check if the request is a web service request within
Application.cfc? Ben Nadel posted that the FORM scope doesn't exist
when a web service is called, but checking against that seems a bit of
an odd way to go about it - there must be a better way?

Blair McKenzie

unread,
May 5, 2011, 10:08:37 PM5/5/11
to cfau...@googlegroups.com
You might be able to check the requested url.

Blair

--
You received this message because you are subscribed to the Google Groups "cfaussie" group.
To post to this group, send email to cfau...@googlegroups.com.
To unsubscribe from this group, send email to cfaussie+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.


Phil Haeusler

unread,
May 5, 2011, 10:18:37 PM5/5/11
to cfau...@googlegroups.com
That's a little odd. Are you doing real webservices or is it actually an Ajax/rest call to your cfc?

BarryC

unread,
May 5, 2011, 11:08:21 PM5/5/11
to cfaussie
It's a real web service, I use this script to call it using the
cfinvoke web service way;
<cfinvoke webservice="http://address-to-file/lib_util.cfc?WSDL"
method="mymethod" timeout="10" returnVariable="returnVar">

The headers show it's a web service. I've seen references around the
net that you can only use isSOAPRequest() in the actual cfc that the
remote method is contained in, so checking for it anywhere outside of
that such as the application.cfc doesn't work.'

I have ended up getting round the issue by just checking for
'application/soap' in the cgi.HTTP_ACCEPT variable (not thoroughly
tested yet though, but should be fine)

Barry.

On May 6, 2:18 pm, Phil Haeusler <philhaeus...@gmail.com> wrote:
> That's a little odd. Are you doing real webservices or is it actually an Ajax/rest call to your cfc?
>
Reply all
Reply to author
Forward
0 new messages