Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

creating a coldfusion webservice to return xml problem

Explorer ,
May 20, 2010 May 20, 2010

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:

http://api.getclicky.com/api/stats/4?site_id=32020&sitekey=2e05fe2778b6&type=visitors,countries,sear...

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

TOPICS
Advanced techniques
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 20, 2010 May 20, 2010
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources