You don't need to ToString the XmlObject it already is a string. If anything you should be using XMLParse() on the incoming argument.
"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 18:26:53 2007 Subject: Re: WebServices - XML Object sent as argument not working correct ly Thank you both for the quick responses. I greatly appreciate your help. I understand what you're saying with this response, but when I pass over XML as a string to coldfusion, it converts the xml string in the SOAP message to an HTML encoded format (i.e. < will become %lt; > will become %gt;) which just doesn't seem right... Is there any chance you could provide an example of how I should define the web service and how to call it? I'm thinking that you mean something along the lines of this, but I'm not sure: Webservice Component: <cfcomponent output="false"> <cffunction access="remote" returntype="string" name="XmlToString"> <cfargument type="string" required="true" name="XmlObject"> <cfreturn tostring(XmlObject)> </cffunction> </cfcomponent> Calling Client: <cfsavecontent variable="xmltext"> <RootNode> <ChildNode>123</ChildNode> <AnotherChildNode>123</AnotherChildNode> </RootNode> </cfsavecontent> <cfscript> ws = createobject("webservice"," http://ksykora.clay/FirstComp/WebService.cfc?wsdl"); result = ws.XmlToString(xmltext); </cfscript> <cfoutput>WebService Result: #HTMLEditFormat(result)#</cfoutput><br /> <cfoutput>Expected Result: #HTMLEditFormat(xmltext)#</cfoutput><br /> <cfoutput>SOAP Request: <cfdump var="#tostring(getsoaprequest(ws))#"></cfoutput> Which when run produces this output: WebService Result: <RootNode> <ChildNode>123</ChildNode> <AnotherChildNode>123</AnotherChildNode> </RootNode> Expected Result: <RootNode> <ChildNode>123</ChildNode> <AnotherChildNode>123</AnotherChildNode> </RootNode> SOAP Request: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:XmlToString soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://FirstComp"><XmlObject xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string"> <RootNode> <ChildNode>123</ChildNode> <AnotherChildNode>123</AnotherChildNode> </RootNode> </XmlObject></ns1:XmlToString></soapenv:Body></soapenv:Envelope> Which if you notice pretty well garbles up the idea of an xml SOAP request. If it's the only workaround I suppose I'll have to deal with it but I'm guessing that people that are actually publishing web services in production environments are doing something else, and I would like to know what that is. Thanks for your continued help! --Ken On 5/24/07, Robertson-Ravo, Neil (RX) <[EMAIL PROTECTED]> wrote: > > Yep, the key is to understand that a ColdFusion XML object is just that... > A > ColdFusion one, so in all reality it's useless to anyone else other than > ColdFusion and even then, only really on your own servers (as I have seen > remote calls fail as well). > > XML is just a well formed string so best to treat it as such and you will > be > happily talking to other languages calling your W/S. > > > > > "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: Robert Rawlins - Think Blue > To: CF-Talk > Sent: Thu May 24 17:35:40 2007 > Subject: RE: WebServices - XML Object sent as argument not working correct > ly > > Yep I'll back Niel on this one, > > I pass XML as a string through web services all the time and it works like > an absolute charm. I talk with all kinds of other apps from JAVA through > to > Python and C. > > Rob > > -----Original Message----- > From: Robertson-Ravo, Neil (RX) > [mailto:[EMAIL PROTECTED] > Sent: 24 May 2007 17:28 > To: CF-Talk > Subject: Re: WebServices - XML Object sent as argument not working correct > ly > > 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> > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279109 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

