Skip to main content
Known Participant
June 30, 2009
Question

CF7/8 - soapenv:Server.userException

  • June 30, 2009
  • 2 replies
  • 3874 views

Hi, I’ve been banging my head against the wall with this one for quite some time now, and I’ve decided to see what the rest of the community thinks about this: I made a very simple webservice:

<cfcomponent>
<cffunction name="init" access="public">
  <cfset CreateObject("java", "coldfusion.server.ServiceFactory").XmlRpcService.RefreshWebService(
   GetPageContext().GetRequest().GetRequestUrl().Append("?wsdl").ToString()
  ) />
</cffunction>

<cffunction name="GetProshops" access="remote" returntype="query">
  <cfquery name="qryProshops" datasource="#application.datasource#">
   SELECT *col1*, *col2*
   FROM *table*
   ORDER BY *col1*
  </cfquery>
 
  <cfreturn qryProshops>
</cffunction>
</cfcomponent>

and when i attach the ?wsdl to the cfc, no problems nicely formatted XML schema. When i exec the function from anywhere (soapUI, VB.NET2008) i get:

<faultcode>soapenv:Server.userException</faultcode>
         <faultstring>org.xml.sax.SAXParseException: Premature end of file.</faultstring>
         <detail>
            <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException..... LONG!

Please help, i really hit rock bottom here. Thanks.

    This topic has been closed for replies.

    2 replies

    Known Participant
    July 1, 2009

    Just incase someone ever has this problem: this is how i fixed it.

    1) I created a sub folder on the same path where the original file (cfc (webservice)) was.

    2) I created a application.cfc for the webservice (in that sub folder I created). (very simple)

    <cfcomponent displayname="Application">
    <cfset this.Name = "[name]" />
    <cfset this.ApplicationTimeout = CreateTimeSpan(0, 0, 1, 0) />
    <cfset this.SetClientCookies = false />
    <cfset this.SessionManagement = false />

    <cfsetting requesttimeout="20" showdebugoutput="false" enablecfoutputonly="false" />

    <cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false">
      <cfset Application.DataSource = "[db dns]">
     
      <cfreturn true />
    </cffunction>

    <cffunction name="OnError" access="public" returntype="void" output="true">
      <cfargument name="Exception" type="any" required="true" />
      <cfargument name="EventName" type="string" required="false" default="" />

     
      <cfsetting enablecfoutputonly="true" />
      <cfoutput><cfdump var="#arguments.EmailOnly#"></cfoutput>

       <cfoutput>Server Error Occurred.<br>
       <cfif arguments.EventName NEQ "">Event: #arguments.EventName#<br></cfif>
       <cfdump var="#arguments.Exception#">
       </cfoutput>

     
      <cfmail from="[email]" to="[email]" subject="Error" type="HTML">
       <cfif arguments.EventName NEQ "">Event: #arguments.EventName#<br></cfif>
       Problem:<br>
       <cfdump var="#arguments.Exception#">
      </cfmail>
     
      <cfreturn />
    </cffunction>
    </cfcomponent>

    3) Moved the old code to the new folder i created (webservice (cfc)).

    ..and it worked. I'm still a bit confused about its behavior, but not complaining. (Scratch that complaining about the amount of time it took me to figure out this fix. LOL)

    Buzzi.

    ilssac
    Inspiring
    July 1, 2009

    Was there an Application.cfc file relevant to the original location of the CFC that had an onRequest() funciton in it?

    The OnRequest() function intercetps every request, even web service requests.  If the onRequest() function is not written to handle web service request, they often introduce errors.

    ilssac
    Inspiring
    June 30, 2009

    kingbuzzman wrote:

      <cfset CreateObject("java", "coldfusion.server.ServiceFactory").XmlRpcService.RefreshWebService(
       GetPageContext().GetRequest().GetRequestUrl().Append("?wsdl").ToString()
      ) />

    What is this line for?  I've never seen it used in a web service before.  One should be very cautious with SerrviceFactory usage.  It is undocumented and unsupported.

    Can you create a function that returns a simple string?  There can be chalanges when using complex data, like the record set you are using, with cross language web services.  I would not use a function like this for my first web service tests.

    Known Participant
    June 30, 2009

    The problem is that coldfusion caches CFCs so you need that line to flush out the cache. I got this from Ben Nadel a while back, have been using it ever since, havent had a problem with it till now. Im still having/getting this error; please someone help me.

    Thanks.

    ilssac
    Inspiring
    June 30, 2009

    Yeah I figured is was something like that.  I just use the built in functions to flush cached web services that do not rely on the service factory.

    Have you tested wether you can return a simple value like a string or a number.  Have you shown your problem is with the web service for the complex data?