There is a bug/feature of ColdFusion web services when passing/returning XML
objects.  It is better practice to pass the data as a string however as it
leads to better interop.

Bottom line, if you want to pass XML, pass it as a string.





"This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant,
Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions." 
Visit our website at http://www.reedexpo.com

-----Original Message-----
From: Ken Sykora
To: CF-Talk
Sent: Thu May 24 16:50:29 2007
Subject: WebServices - XML Object sent as argument not working correctly

Hi Everyone - I posted this on the Adobe forums but have so far had no luck
with any responses.

I'm having trouble with coldfusion web services and am hoping that someone
here can reproduce this error and provide some insight to this issue.

I'm trying to create a web service, and in the web service it takes an XML
object as an argument. Inside the web service code I want to convert the XML
object to a string so I can store it in a database. The problem is that
whenever I convert the xml object to a string (using the ToString(xmlobj)
method) in the web service call, it returns the xml string as '[#document:
null]'. However, when I perform the same operation on the test page that is
calling the web service, it converts the xml object correctly to a string
with the raw XML.

I am using ColdFusion MX 7 version 7,0,2,142559

If you can reproduce this error, please let me know. If you have a solution,
please!!!! let me know. This is very frustrating... I've been battling this
issue for about a day now. 

I can work around this issue by passing the XML as a straight up string and
then perform an XMLParse() on the web service, but that is borderline
unacceptable.

Please see the sample code below.

Webservice Component:

<cfcomponent output="false">
       <cffunction access="remote" returntype="string" name="XmlToString">
               <cfargument type="xml" required="true" name="XmlObject">
               <cfreturn tostring(XmlObject)>
       </cffunction>
</cfcomponent>

Test Page:

<cfsavecontent variable="xmltext">
<RootNode>
       <ChildNode>123</ChildNode>
       <AnotherChildNode>123</AnotherChildNode>
</RootNode>
</cfsavecontent>
<cfscript>
       ws =
createobject("webservice","http://ksykora.clay/WebService.cfc?wsdl";);
       xmlObject = xmlparse(xmltext);
       result = ws.XmlToString(xmlObject);
</cfscript>
<cfoutput>WebService Result: #HTMLEditFormat(result)#</cfoutput><br />
<cfoutput>Expected Result: #HTMLEditFormat(ToString(xmlObject))#</cfoutput>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279093
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to