Returning XML with CFC call through URL

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Returning XML with CFC call through URL

    Hey peoples. What I'm doing is using JavsScript to call a CFC via a URL, and
    this JavaScript can use XML that's returned and then do all kinds of neat stuff
    (for anyone who's familiar with the term, I'm using this as part of an AJAX
    implementation). Since I'm using a <cfreturn> in the CFC, it returns a WDDX
    packet. Which is great, since it's XML, however there are dozens of blank
    lines before the packet starts. As far as the JavaScript is concerned, I just
    tried to return nothing. My guess is that the extra lines make the XML invalid
    and JavaScript won't parse it. My CFC call is something like:

    [url]http://www.mysite.com/components/general.cfm?method=getPrice&sku=1234[/url]

    I've got whitespace management turned on in the Administrator, but it's not
    cutting all of it out. Is there any way to get rid of this whitespace so
    JavaScript will play nicely? In Flash there's a handy .ignoreWhite property
    that would fix my problem lickety split!

    I guess in the worst case senario I can run a RegEx on the returned text and
    let JavaScript remove all of the extra white space, then parse what's left over
    as XML, but I'd rather do it the "right" way. Thanks!

    Cannikinn Guest

  2. Similar Questions and Discussions

    1. CFC Call Hanging on Second Call
      I run the flex application localy using the demo/dev server and do a search using a CFC, and then do another and its fine. But when my boss tries,...
    2. connection_status() always returning 0
      Dear all, My spec: RedHat 8.0 Apache 2.0.40 PHP 4.2.2 I used the following code: set_time_limit(0);
    3. Returning Dataset
      I have been working on a .NET application architecture for a client for the past several months based on many of the patterns & practices described...
    4. Returning to a form
      Hello I hope someone can help me. I have a form page a user needs to fill out. I want to be able to send the user back to the form once it is...
    5. remote call procedure call failed
      Also, it says error 1726 "remote call procedure call failed" Help, Unable to save username and password in XP Home edition. It allows me to...
  3. #2

    Default Re: Returning XML with CFC call through URL

    Check out cfsilent and cfsetting:-

    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-pc6.htm#wp1103514[/url]

    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-pc7.htm#wp1103549[/url]
    Stressed_Simon Guest

  4. #3

    Default Re: Returning XML with CFC call through URL

    I thought of those, but how are you supposed to use those in a component or
    application.cfc? I can't put <cfsilent> before the <cfcomponent> tag or else
    it isn't a valid component anymore. If I put it after, then the actual
    <cfcomponent> line itself causes a blank line.

    Cannikinn Guest

  5. #4

    Default Re: Returning XML with CFC call through URL

    >I can't put <cfsilent> before the <cfcomponent> tag or else
    > it isn't a valid component anymore.
    You're not calling the component, though, are you? You're calling a
    *method* of the component. Make sure you've got output="false" on your
    method, and consider using <cfcontent> to set the mime type of the returned
    data to text/xml (or whatever the correct mime type for XML is... I'm
    guessing at that).

    --

    Adam
    Adam Cameron Guest

  6. #5

    Default Re: Returning XML with CFC call through URL

    Hey, a fellow Cameron! I'm Rob Cameron. :)

    You're right, I'm calling a method, but I think whitespace comes in even from
    the Application.cfc page, and there's tons of whitespace all over that thing.
    I ended up using a RegEx on the text that's returned by the call, seems to work
    just as well. Plus I don't have to try and work my way through the XML tree,
    just one long RegEx does it all. Thanks!

    Cannikinn Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139