Copy link to clipboard
Copied
Hi I am creating a coldfsion webservice that is to be used by other platforms ( asp etc). In my webservice I have a method that I want to return data as XML which can then be read easily by these different platforms. At the moment I have something like this....
<cffunction name="getBlogs" hint="I search the live blogs" access="remote" returntype="xml">
<cfargument name="limit" required="No" default="" type="any">
<cfargument name="blogCategoryTypeName" required="No" default="Web analytics" type="any">
<cfset var qrySearch = "">
<cfset var strXML = "">
<cfquery name="qrySearch" datasource="#variables.dsn#">
select
blogsLive.blogId
, blogsLive.blogHeadline
, blogsLive.blogSummary
from
blogs
where
blogslive.blogStatusId = 2
</cfquery>
<cfsetting enablecfoutputonly="true" />
<cfprocessingdirective suppresswhitespace="yes">
<cfxml variable="objXML">
<cfoutput>
<blogs>
<cfloop array="#results#" index="b">
<blog id="#b['blogId']#">
<headline>#XMLFormat(b['blogHeadline'])#</headline>
<summary>#XMLFormat(b['blogSummary'])#</summary>
</blog>
</cfloop>
</blogs>
</cfoutput>
</cfxml>
<cfset strXML = #ToString(objXML)#>
<cfset strXML = #replace(strXML,"<?xml version=""1.0"" encoding=""UTF-8""?>","")#>
</cfprocessingdirective>
<cfreturn strXML>
</cffunction>
The problem I am having is that when calling this webservice via classic ASP for example it sees the xml as a string and hence it quite difficult to manipulate. I would like to return the data like the following example:
How can i get the webservice to return data like the link above? So for example if i call mty webservice like link above i get the same type of result?
Any help much appreciated
Copy link to clipboard
Copied
I've had similar issues. I've been asked to write web services for asp.net apps and basically, if you include the opening xml tag, asp can't consume it. I handled my own problem by including an argument that determined whether to return the data with the xml tag or without.