Pete Freitag Pete Freitag

ColdFusion SOAP Web Services and onRequestStart

Published on November 19, 2009
By Pete Freitag
coldfusion

I knew there are some issues with using onRequest in your Application.cfc and web services, but I didn't think there were any issues with onRequestStart and ColdFusion 8 SOAP web services.

Today while working on one of my clients web services I started getting the error org.xml.sax.SAXParseException: Premature end of file. on any web service call. The web service worked fine a few days ago.

The problem was that another developer added the following to the existing onRequestStart:

<cfset var headers = GetHttpRequestData().Headers>

Apparently will cause bad things to happen. As a workaround I thought this would be a great use for the function IsSOAPRequest() added to CF7, I've never used it.

Well it turns out that IsSOAPRequest() always returns false in onRequestStart! (On ColdFusion 8, I haven't tested this on 9)

I ended up using arguments.targetPage to condition calling GetHttpRequestData() and all was well.

Here's the full stack trace I was getting:

org.xml.sax.SAXParseException: Premature end of file.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
	at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
	at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
	at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
	at org.apache.axis.server.AxisServer.initSOAPConstants(AxisServer.java:345)
	at org.apache.axis.server.AxisServer.invoke(AxisServer.java:279)
	at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
	at coldfusion.xml.rpc.CFCServlet.doAxisPost(CFCServlet.java:270)
	at coldfusion.filter.AxisFilter.invoke(AxisFilter.java:43)
	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273)
	at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
	at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:138)
	at coldfusion.xml.rpc.CFCServlet.doPost(CFCServlet.java:289)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at jrun.servlet.FilterChain.service(FilterChain.java:101)
	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
	at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)


coldfusion soap axis onrequeststart issoaprequest application web services

ColdFusion SOAP Web Services and onRequestStart was first published on November 19, 2009.

If you like reading about coldfusion, soap, axis, onrequeststart, issoaprequest, application, or web services then you might also like:

Fixinator

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.


Try Fixinator

CFBreak
The weekly newsletter for the CFML Community


Comments

The documentation for isSOAPRequest() is very odd; maybe because it is unclear, or maybe because I just never used the method. From what I could gather, it looks like isSOAPRequest() is intended to only work from *within* the CFC being invoked.

In the docs, under usage, it says:

"Call this function within a CFC to determine if it is running as a web service."

So, I think it might not work unless it is being called from within the target CFC. Odd method if that is the case.
by Ben Nadel on 11/20/2009 at 3:11:16 PM UTC
Ben, thanks, that makes sense, but it would be nice if it also worked in Application.cfc for uses I pointed out in the entry.
by Pete Freitag on 11/20/2009 at 3:45:04 PM UTC
Yeah, completely agree. In fact, having it inside the target CFC seems kind of useless :)
by Ben Nadel on 11/20/2009 at 3:46:17 PM UTC
Lost half a damn day to this. I couldn't find a report of this in the public bug tracker, so I filed a new report. Thanks Pete.
by Raymond Camden on 04/29/2010 at 4:10:04 PM UTC