ColdFusion SOAP Web Services and onRequestStart
By Pete Freitag
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 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:
- PostalMethods - Web Service for Snail Mail
- Going from SOAP to REST Web Services
- Web Services Problems with ColdFusion 8 on a Mac
- REST vs SOAP Web Services
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
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.