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

Catching HTTP content under CF5

New Here ,
Nov 17, 2006 Nov 17, 2006

Copy link to clipboard

Copied

Hello

I'm running ColdFusion 5 (yes, I know it's quite outdated...) under Solaris and try to catch posted data in the CF-page for further processing. According to the documentation, GetHttpRequestData() looks like what would do the job.

Here's the sample code:


<cfoutput><pre>
BEGIN
<cfset request = GetHttpRequestData()>
#request.content#
END
</pre></cfoutput>



Now I send the following request to CF:

[request]
telnet myhost.example.com 80
POST /SOAP/Soap.cfm HTTP/1.1
Host: myhost.example.com
Content-Type: application/soap+xml
Content-Length: 15

aaa
bbb
ccc

[/request]


The variable "request.content" seems to be completely empty though. What am I missing? Isn't it possible to simply catch the raw content of a POST in CF5?

Kind regards,
Daniel
TOPICS
Advanced techniques

Views

459

Translate

Translate

Report

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
New Here ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Hi

Is there _anyone_ who can say anything to this, please? 🙂 A "it works for me" would help too. :)

I've found several messages on the Internet from from people who experience the same problem:

http://www.houseoffusion.com/groups/CF-Talk/thread.cfm/threadid:24200
http://www.houseoffusion.com/groups/CF-Talk/thread.cfm/threadid:18584
http://www.cs.miami.edu/students/strac/svg/files/arrows.html

Comments? Ideas? Shrieking epitaphs?

Kind regards
Daniel

Votes

Translate

Translate

Report

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 ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

hmmm...I use it on a windows server with cf 5 and I'm pretty sure it
works (don't have access to that server anymore), don't know about
Solaris. Maybe it's something to do with the name of your variable?
"request" is used by CF as a scope. try renaming your variable?
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com

Votes

Translate

Translate

Report

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
New Here ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Hello

Thanks for your answer! The renaming didn't help but my quoted example was not really the one I've tried. ;)

When changing the content-type to "text/xml", everything works fine. The documentation says that if the content-type is neither "text/..." nor "application/x-www-form-urlencoded", the content itself will be stored as a binary object. This binary object seems to be empty though. When writing it to a file, the file is empty. When checking with the isBinary() function, CF5 tells me it's not binary object. And finally converting it with toString() also doesn't help. (it stays empty)

Any pointers what else I could try?

Many thanks in advance! :)
Daniel

Votes

Translate

Translate

Report

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
Participant ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

The 'content' of getHTTPrequestData() return, in either string or binary format, the form data that was submitted by the client. It does not return the page content. (At least this is how it works in 6.1).

Your 'content' is empty because you are not passing any form data.

If you want to interrogate the page data... try using CFSAVECONTENT and interrogate the variable to get what you need ;)

Hope this helps :)
Peter

Votes

Translate

Translate

Report

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
New Here ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

Hallo SpiderFromMars :)

But I _want_ all the data the client was sending. The documentation of GetHttpRequestData() says "Makes HTTP request headers and body available to CFML pages.", which is exactly what I want. It goes on by saying this is expecially useful for capturing SOAP requests - which again is exactly what I want.

The tag CFSAVECONTENT on the other hand seems to be good for 'capturing' the server-side generated response in a CF-variable before actually sending it to the client.

So I'm kinda confident that GetHttpRequestData() is what I want here. Either that or I misunderstood you and/or the CF5 documentation. :)

Kind regards
Daniel

Votes

Translate

Translate

Report

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
Participant ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

Hi Daniel:

How are you receiving the data from the client? Are you using CFHTTP? If so, use the cfhttp.filecontent variable. If you are using another method, let me know and I'll help you find something else.

The LiveDocs do indeed state that the body of the message is displayed, but <all_hail>Ben Forta's</all_hail> Web Application Construction Kit states that the content only contains form data. I ran a few tests and this is indeed the case. Forta: right. Livedocs: not-so-right :->

Cheers,
Peter




Hallo SpiderFromMars :)

But I _want_ all the data the client was sending. The documentation of GetHttpRequestData() says "Makes HTTP request headers and body available to CFML pages.", which is exactly what I want. It goes on by saying this is expecially useful for capturing SOAP requests - which again is exactly what I want.

The tag CFSAVECONTENT on the other hand seems to be good for 'capturing' the server-side generated response in a CF-variable before actually sending it to the client.

So I'm kinda confident that GetHttpRequestData() is what I want here. Either that or I misunderstood you and/or the CF5 documentation. :)

Kind regards
Daniel

Votes

Translate

Translate

Report

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
New Here ,
Jan 10, 2007 Jan 10, 2007

Copy link to clipboard

Copied

Hi Peter

No, I'm not doing cfhttp. In my case, the client sends a SOAP message to a ColdFusion page and I'm trying to access this SOAP message in the CF-page to process it further.

The client sends something like this:

POST /SOAP/Soap.cfm HTTP/1.1
Host: myhost.example.com
Content-Type: application/soap+xml
Content-Length: nnnn

<SOAP-ENV:Envelope>
....
</SOAP-ENV:Envelope>


In CF I would like to get access to the XML-document "<SOAP-ENV:Envelope>" in the body.

If the client uses "text/xml" as content-type, I can access the XML-document with GetHttpRequestData().content. If the content-type is "application/soap+xml" though, GetHttpRequestData().content is simply empty. According to the CF documentation it should be a binary object though.

I will ask the customer, whether she can send "text/xml" as content-type instead, but as you know customers, that prolly won't work :)

If I could use Apache2, I could change the content-type on the server side with the mod_headers module, but since the CF5-module is not available/supported under Apache2, that's also a no-go. :(

Any hints would be greatly appreciated. :)

Kind regards
Daniel

Votes

Translate

Translate

Report

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
Participant ,
Jan 10, 2007 Jan 10, 2007

Copy link to clipboard

Copied

Hi Daniel:

This is quite interesting and leaves me a bit stumped.

The easiest (but most expensive) way woudl be to update to CFMX 7.0 and then write a web service to consume this package.

You also might want to check: http://www.activsoftware.com/xml/

There are some useful XML tools there that will work with 5.0. The SOAP tool they have there, though, appears only to send requests and not process incoming ones.

Please keep me posted on this! I'd like to know the solution.

Peter

Votes

Translate

Translate

Report

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
New Here ,
Jan 12, 2007 Jan 12, 2007

Copy link to clipboard

Copied

LATEST
Hey Peter

Upgrading to CF7 is even more unthinkable than upgrading just Apache. 🙂 So I think I'll try to convince our customer instead. If I stumble over another solution, I'll post it. :)

Thanks!

Daniel

Votes

Translate

Translate

Report

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
Documentation