1 Reply Latest reply on May 20, 2010 5:09 AM by Dan Bracuk

    creating a coldfusion webservice to return xml problem

    zubair

      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,coun tries,searches

       

      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