Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

receiving and XML file and sending back a response

0 views
Skip to first unread message

Linton Grieves

unread,
Nov 1, 2003, 10:42:36 AM11/1/03
to
Dear All,

I am trying to effectively do the reverse of a CFHTTP post of an xml file. I am working on collaboration with another company and we need to send xml documents to and from each other. I can post my xml files to them happily using the CFHTTP command and happily receive a response back.

What I need to do is allow them to do the same (send files to me and me give a response) using what ever language they are using. I need to receive their xml file, process it and send back a response.

I have tried all sorts of combinations cfhttp but to no avail, I have looked on this listing again with no luck. I am using CF5 on win2K and an SQL system.

If anyone can help, it really would be appreciated.

Thanks

Lee


Trygve

unread,
Nov 2, 2003, 11:16:15 AM11/2/03
to
Have you tried using GetHttpRequestData() and paring the result?

<!--- Get requestdata in a struct --->
<cfset xml = GetHttpRequestData()>

<!--- Transfer struct content to a string --->
<cfset xmltest = ToString( xml.content )>

<!--- Parse string into an XML document object --->
<cfset myXMLDocument = XmlParse( xmltest )>

trygve


Linton Grieves

unread,
Nov 2, 2003, 4:48:55 PM11/2/03
to
Dear Trygve,

Thanks for the reply, but not sure how this works, I have looked at the GetHttpRequestData() function in CF Studio and have looked at the sample code. I have attached my post page below and then the page to which is submits using the code from the example which I would have thought would have returned a structure to the CFHTTP.filecontent variable but to now avail.

I know I am being dim somewhere but not sure where.

Regards,

Lee
### INPUT PAGE ###

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>

<cfset test_var = "test data">

<cfhttp url="http://dev.sportfocus.com/reguser/DynaBizInfo/LF_mobile_test.cfm" method="POST">
<cfhttpparam name="Data" value="#test_var#" type="FORMFIELD">
</cfhttp>

<cfoutput>#cfhttp.filecontent#</cfoutput>

</body>
</html>

### RECEIVING PAGE ###

<cfset x = GetHttpRequestData()>
<cfoutput>
<table cellpadding = "2" cellspacing = "2">
<tr>
<TD><b>HTTP Request item</b></td>
<td><b>Value</b></td>
</tr>

<cfloop collection = #x.headers# item = "http_item">
<tr>
<td>#http_item#</td>
<td>#StructFind(x.headers, http_item)#</td>
</tr>
</cfloop>

<tr>
<td>request_method</td>
<td>#x.method#</td>
</tr>
<tr>
<td>server_protocol</td>
<td>#x.protocol#</td>
</tr>
</table>
<b>http_content --- #x.content#</b>
</cfoutput>



MothraStewart

unread,
Nov 3, 2003, 8:05:00 PM11/3/03
to
Hi, if I understand your problem correctly, cfhttp is not required for receiving XML. Since the other party is posting an XML document to one of your pages, you do not have to do any http requests yourself. I assume they are posting a form containg a input with the XML to your webserver. The page that they access will have form variable availabel to it which you can do what you please with.

If their page is posting a form with XML in it like this:

<form action="yourCFMpage.cfm" method="post">
<input type="text" name="foo" value="----XML HERE ----">
</form>

A simple version of your page will look like this:

<cfparam name="form.foo">

<cfset xmlFoo = xmlParse(form.foo)>

<!---- Code here to process XML --->

<!--- put code here to output reply, this would be returned in the http request they made --->

Hope this helps
-m



Linton Grieves

unread,
Nov 4, 2003, 5:08:40 PM11/4/03
to
Thanks MothraStewart,

Realised what the problem was. I was using cfhttp effectively to test a file on the same server which was throwing an error. As soon as I put the submitting page on another server it pulled back the correct information. Thanks for your help. I can now move on with my project.

Regards,

Lee


0 new messages