Skip to main content
Participant
February 26, 2014
Question

Calling Webservice removes root element of XML

  • February 26, 2014
  • 1 reply
  • 846 views

Hello community,

I am experiencing a problem in context with ColdFusion 10 and webservices.

My webservice creates some XML content, parses it with the XMLParse() function and returns it with returntype="xml".

Testing it with an additional .cfm script (I invoke the webservice with cfinvoke, as you can see below) I noticed that the root element of the xml is missing - so does every child of the document root except the first one.

If I run my test script on a ColdFusion 8 server everything works fine and the xml content is just as expected.

Some information about my local server configuration:

Windows 7

IIS 7

ColdFusion 10

Here is my webservice.cfc

<cfcomponent output="false">

    <cffunction name="testFunction"

                access="remote"

                returntype="xml"

                output="false">

        <cfset var local = {} />

        <cfsavecontent variable="local.string">

            <rootElement>

                <child>1</child>

                <child>2</child>

            </rootElement>

        </cfsavecontent>

        <cfreturn XMLParse(Trim(local.string)) />

    </cffunction>

</cfcomponent>

My test script caller.cfm:

<cfinvoke webservice="http://localhost/returntype_xml/webservice.cfc?wsdl"

refreshwsdl="true"

method="testFunction"

returnvariable="someVariable">

</cfinvoke>

<cfoutput>

    <pre>#HTMLEditFormat(someVariable)#</pre>

</cfoutput>

<cfdump var="#someVariable#" abort="false">

The generated wsdl (outsourced to pastebin):

http://pastebin.com/VJaU7AMw

and finally the output that my test script (caller.cfm) generates:

<?xml version="1.0" encoding="UTF-8"?>

<child>

1

</child>

As you can see, most of the xml content is missing.

Calling the function directly (/webservice.cfc?method=testFunction) works quite well, thats why I suppose that the webservice call causes the problem.

Does anybody know what the source of the problem might be? Or ist maybe a known bug?

Best regards,

Stefan

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
February 27, 2014

Array and XML may be universal complex types, however, I would never trust that ColdFusion's proprietary interpretation of these types would work outside the CFML language. That is, if a ColdFusion function returns an array or XML, I would not presume it will be interpreted as such by a Java or PHP program, for example.

The most common, universal way of implementing XML webservices in ColdFusion is to use returntype="string". Another, not so common, way is to construct a SOAP response.

In any case, you should report your findings as a bug. If ColdFusion cannot handle the XML, it should return an error message, instead of an edited version of the XML.