Pass XML string to a URL

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Pass XML string to a URL

    I need to pass a xml string to the URL. and return I will get a XML response.
    I need to pass the varible in an online form and send the result in XML to a
    online http xml application.
    Below is a PHP sample. How can do the same in Coldfusion? CFhttp ?



    $sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    $sXML .= "<ZipCodePing><zip>" . $zip . "</zip>";
    $sXML .= "<Country>" . $country . "</Country>";
    $sXML .= "<affid>" . $affid. "</affid>";
    $sXML .= "<password>" . $pass. "</password></ZipCodePing>";

    $fp = fsockopen($url, $port, $errno, $errstr, 30);

    if(!$fp) {
    echo "$errstr ($errno)\n"; //tell us error
    } else {
    //send the server request
    fputs($fp, "POST " . $path . " HTTP/1.1\r\n");
    fputs($fp, "Host: " . $url . "\r\n");
    fputs($fp, "Content-type: application/xml\r\n");
    fputs($fp, "Content-length: " . strlen($sXML) . "\r\n");
    fputs($fp, "Connection: close\r\n\r\n");
    fputs($fp, $sXML);

    $getit = "";
    while(!feof($fp)) { // get the response
    $getit = $getit . fgets($fp, 4096);
    }

    fclose($fp);

    echo $getit; // displays the response
    }
    ?>


    Thanks in advance...





    CF_error Guest

  2. Similar Questions and Discussions

    1. Why can I pass a string, but not a date?
      I have this custom component that at the moment just repeats the passed in value. It works if I pass in a string, but if I pass the date I...
    2. & in a string to pass through url param
      I am trying to add a list/menu in DW2004, and for each option I need to pass url paramerters the problem I am having is concantinating &amp; in a string...
    3. How to pass <br> string to webservice ?
      Greetings, I have asp.net page with a textbox. This textbox is used to pass values(mainly strings) to VB.NET webservice using...
    4. Pass String Variable from Flash MX to Director MX
      Is there any way for me to pass a string variable from Flash MX to Director MX? The line of code I'm using in Flash where I'd like to pass the...
    5. Using query string to pass a value to a stored procedure parameter
      All, I want to push on a form button in an HTML page and pass a query string to the ASP.NET page I’m opening. That query string has the...
  3. #2

    Default Re: Pass XML string to a URL

    Just curious if you were able to convert your PHP to CF. I am looking at doing a similar thing.

    J.
    USA Jon 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