CF WEBSERVICES  BUG?  Can't return an array from a CFC?

Posted on 2006-05-21
Last Modified: 2013-12-24

This has to be either my coding error (most likely), or a bug in CF.

We are using CF 7+.  I "CAN" see the WSDL file in the URL.  My query does return dat.a  I can get the webservice to work when I return a string, a structure, or a query object.  When I am trying to return this array it fails. The actual error message is at the "very" bottom of this post.  Also, both cfc's are in the same directory as the calling file which in this case is just an index.cfm page.  I can get it to work as a webservice, but not when I return a datatype of "array".

Here is the CFC

<cfcomponent output="false" name="userService.cfc">

      <cffunction name="getUsers" access="remote" returntype="array">
            <cfset var q = "" />
            <cfset var a = arrayNew(1) />
            <cfset var u = "" />
            <cfquery name="q" datasource="mydsn">
                  SELECT *
                  FROM t_User
            <cfloop query="q">
                        u = createObject("component","User");
            <cfreturn a />

Here is the CFC call:

<cfset wsURL = "http://localhost:8500/someDirA/someDirB/userService.cfc?wsdl" />

      users = CreateObject("webservice","#wsURL#");
      a = users.getUsers();

<cfdump var="#a#">

Could not perform web service invocation "getUsers".  
Here is the fault returned when invoking the web service operation:

 faultCode: {}Server.userException
 faultString: org.xml.sax.SAXParseException: Premature end of file.
      {}stackTrace: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(S...
If anyone can assist, this would be greatly appreciated.



Question by:Westside2004
    1 Comment
    LVL 7

    Accepted Solution

    This is just a guess, but if you are using Internet Explorer to test the WSDL, you may be missing a syntax problem that exists in the return XML. IE is famous for "nice" rendering where a closing tag is omitted. I would test it with Firefox or Opera and see if it still looks the same. I have a feeling this will show you where the problem is.


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now