GetHTTPRequestData() Breaks The SOAP Request / Response Cycle In ColdFusion

Posted June 5, 2009 at 8:38 AM by Ben Nadel

Tags: ColdFusion

Yesterday, when I was experimenting with SOAP request error handling inside of the ColdFusion application framework, I came across what I think is a ColdFusion bug. It seems that if you call ColdFusion's GetHTTPRequestData() method during a SOAP request, the method executes properly, returning the HTTP request data, but it breaks the SOAP response, throwing the following error:

org.xml.sax.SAXParseException: Premature end of file.

To see this in action, check out this video:

 
 
 
 
 
 
 
 
 
 

In the video, I am using CFDump to output the GetHTTPRequestData() to an external file:

Application.cfc

  • <cfcomponent
  • output="false"
  • hint="I provide application settings and event handlers.">
  •  
  • <cfsetting showdebugoutput="false" />
  •  
  • <cftry>
  •  
  • <cfdump
  • var="#GetHTTPRequestData()#"
  • format="html"
  • output="#ExpandPath( './soaprequest.htm' )#"
  • />
  •  
  • <cfcatch>
  •  
  • <cfdump
  • var="#CFCATCH#"
  • format="html"
  • output="#ExpandPath( './soaprequest.htm' )#"
  • />
  •  
  • </cfcatch>
  •  
  • </cftry>
  •  
  • </cfcomponent>

... however, the same error occurs even I simply call GetHTTPRequestData() and store the result into the Application.cfc public scope:

  • <cfset this.test = GetHTTPRequestData() />

So, it's clearly not a problem with CFDump, but rather with the invocation of the GetHTTPRequestData() method itself. Unless I am missing something obvious here, this appears to be a bug in the way that GetHTTPRequestData() interacts with SOAP-based requests. Any thoughts?




Reader Comments

Jun 5, 2009 at 8:54 AM // reply »
30 Comments

Yep, I ran into this issue when using CF to secure a webservice via Basic Auth: http://www.mischefamily.com/nathan/index.cfm/2008/8/13/Basic-Authentication-With-ColdFusion

I can't remember if I reported it as bug or not.


Jun 5, 2009 at 9:00 AM // reply »
11,246 Comments

@Nathan,

No problem, I just submitted it as a bug.


Jul 8, 2009 at 9:56 AM // reply »
2 Comments

Ben, did you get any fix for this. i am having the same issue. i do have a soap webservice which is not serving any wsdl, i am trying to access that but i am getting the the same error you are getting. can you post the complete code including soap header etc...thanks.


Jul 8, 2009 at 10:00 AM // reply »
11,246 Comments

@Manju,

There is no fix for this at the moment, other than to not use GetHTTPRequestData() in conjunction with SOAP web services calls, as far as I know. Perhaps Adobe will fix this bug in later releases.


Jul 8, 2009 at 10:08 AM // reply »
2 Comments

i have couple questions.
i have a webserver i need to access invoke some soap web servies. but there is no wsdl served by the server( it is a third party server built in some C# or so). but i have a wsdl the company sent me can i save that on to my server and point that to web service hosting server and use that. is that possible....some one on the web said it is possible. i never did anything like that. untill now what ever i use had WSDL so i used direct cfinvoke...that's it. now i am trying to use soap route...

if i can not use the above method (saving wsld locally) or get HTTP then what other route i can go...let me know and post me some sample code.. thanks for your help


Jul 12, 2010 at 9:37 AM // reply »
3 Comments

I know that this is from a long time ago, but am experiencing this error with a PDF form submission script I made.

At the beginning of the CF submission script on the server, it grabs the request content using GetHTTPRequestData(), makes it into a string, and then uses ParseXml to make it into XML data. From here, it can (or at least should) be able to traverse the data as if it was an XML file.

99% of the time, everything works fine, however, I am occassionally getting this "Premature end of file error" that I believe is sprouting from the GetHTTPRequestData(). On an error, I have the script send me an email that contains the XML data that was grabbed from the GetHTTPRequestData(), and when I get this error, the email never contains any XML markup.

So, since I have not found out elsewhere what is going on with this, I thought I would try here...


Jul 12, 2010 at 10:30 AM // reply »
11,246 Comments

@Justin,

It sounds like you script is fine - that something is going from with the HTTP Post to your page. If no XML is showing up in the getHTTPRequestData(), then perhaps none is actually being posted. Do you have control over the environment that is posting TO your scripts?


Jul 12, 2010 at 10:57 AM // reply »
3 Comments

These posts are being made via a submit button on a PDF form. The form is set to send XML markup to a script sitting on my server. Aside from being able to touch the PDF form, I really do not have access to the other side of things. (All of the testing we did before we launched went through just fine.)

These are used to register people for a competition at a university I work for as a student worker. Basically, the form is downloaded, filled out, and submitted, which should result in the XML data being sent in a request to the script.

I have been going back and forth between thinking that it is my script, or something in the transmission. Once I read a few places that such an error was occurring with GetHTTPRequestData() and I used that function in my code, I was thinking that maybe that was causing the issue.

The really weird thing for me is the inconsistency of the error. I would think that using Adobe Reader/Acrobat to submit a registration form would allow for easy use by people on Windows or Mac, and that using Adobe software for all submissions would result in the same functionality (the people who have had this issue have been using newer versions of Reader).

But, I would think that if it is just a transmission issue with the request, that it would eventually go through. Some people have tried submitting their registrations many times, at different times of the day (or days later), and the error is still thrown.


Jul 12, 2010 at 2:51 PM // reply »
11,246 Comments

@Justin,

Yeah, you'd definitely think that using something like Acrobat would maintain a consistent experience. I don't have much experience with it - perhaps the application allows you turn on and off features for "security" purposes; this might be messing with posts.

One thing to try on your own is to get the PDF and submit the form with a LOT of data - like any free form textarea, just load it up with a ton of text. It's possible that the POST size gets too big and ColdFusion is trying to handle it another way. In ColdFusion 9, I think once a POST size gets to a certain point, it actually is handles through different means (for memory optimization) and is no longer available via getHttpRequestData().... of course, I could just be making that up... but it's something worth trying.


Jul 12, 2010 at 3:51 PM // reply »
3 Comments

I'll try that. Thanks for taking the time to help me out. I've been to your site quite a few times before, and it's always been helpful. Keep up the great work!


Jul 18, 2010 at 12:19 PM // reply »
11,246 Comments

@Justin,

Thanks my man - good luck with the intercepting SOAP stuff; it is definitely a major pain in the butt that it breaks the incoming request.


Oct 29, 2010 at 4:26 AM // reply »
1 Comments

I am about to face the same problem as I do need to capture a custom HTTP header in web service calls. I am wondering if anyone has experimented with filter chains. We have done it successfully before to address buggy soap client. I will try a similar approach by processing a request before Cold Fusion gets to do it. I just need to pick the existing header that exists in the CGI scope to overwrite it with the custom one. Any thoughts, suggestions, comments?


Nov 1, 2010 at 9:15 PM // reply »
11,246 Comments

@Henry,

You might try poking around in the GetPageContext() method:

http://www.bennadel.com/blog/758-ColdFusion-GetPageContext-Massive-Exploration.htm

I believe it should allow you access to the request headers without having to go to the getHttpRequestData() function. I'll see if I can take a look at this as I think this is a problem a lot of people will run into.


Jul 28, 2011 at 12:55 PM // reply »
1 Comments

The workaround I use is: getPageContext().getRequest().getHeader("name of header here") to retrieve the request header I'm looking for. This doesn't break to SOAP calls like getHttpRequestData.


Sep 14, 2011 at 3:22 PM // reply »
7 Comments

This bug is still alive and kicking even on ColdFusion 9.0.1. Please vote for this bug in the Adobe bug tracker. Its bug #82776 at http://cfbugs.adobe.com


Oct 19, 2011 at 8:58 PM // reply »
16 Comments

I'm investigating a report of this error for a RESTful Webservice. Our webservice uses GetHTTPRequestData().content to suck out HTTP body which is expected to only contain the XML data as a POST request. My own client that invokes this webservice operates correctly, simply posting the XML as a string with a cfhttpparam of type text/xml.

I'm wondering if anyone has encountered the Premature End of File error with RESTful web services, or more generally when using GetHTTPRequestData but not in the context of a SOAP request.

Thanks!


Oct 19, 2011 at 9:23 PM // reply »
16 Comments

I'm thinking that the real client that invoked our webservice may have tried to invoke it with SOAP instead of a RESTful POST. I've not found any useful cross references for that error and REST, except for Ben's other blog on intercepting SOAP to convert to REST.


Oct 20, 2011 at 11:53 AM // reply »
16 Comments

Ok, we resolve this problem. Our RESTful web service and the rest of the webtop is available over port 443 on HTTPS. The client was posting to the web service over HTTP instead. When IIS redirected the client POST from http to https, the XML payload was being stripped off, thus causing the XMLParse to throw then exception attempting to parse no input, which was expected to be obtained with GetHTTPRequestData().content.


Jan 31, 2012 at 12:13 PM // reply »
19 Comments

Another Google search brings me to a post of your's Ben and solves my problem. FYI, this still exists in CF9 as far as I can tell. It turned out I had a pre-process that used GetHTTPRequestData function in my OnRequestStart function for the rest of the app.


Jul 17, 2012 at 1:18 AM // reply »
6 Comments

Hi Ben have you experienced any issues capturing request data using GetHTTPRequestData over HTTPS? I've had a system whereby we capture the SOAP content from a 3rd party system over HTTP and it has worked successfully for 12 months, and recently they have started sending to us over HTTPS and the SOAP content is empty? Headers are in tact but body content is blank. Bizarre?



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 24, 2013 at 9:11 AM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Brandon, Hi, No, I haven't been able to do that. I have just kept it as it is. ... read »
May 23, 2013 at 9:52 PM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Muhmmadibn Did you figure out a solution to launching PDFs? I am running into the same issues myself. There is no way to close the PDF or go back once you launch it. Thanks in advance! ... read »
May 23, 2013 at 6:06 PM
The Girl Who Broke My Heart, And Made Me A Better Person
Good day,ladies and gentle men, my name is Dr AMADI the great spell caster in Africa, i have help so many people for different kind of problems,who say there is no solution to problems on earth, that ... read »
May 23, 2013 at 4:26 PM
ColdFusion QueryAppend( qOne, qTwo )
@Heather, Glad people are still getting value out of this! ... read »
May 23, 2013 at 3:49 PM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, I meant the code at the bottom (not the video). I did try to experiment with an intermediary variable, like: value = users.id[ i ]; arrayContains( userIDs, value ); ... but t ... read »
May 23, 2013 at 11:06 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Are you talking about As Number: YES As String: YES As Java: YES? If so, that's with 3 different ways of referencing the constant 1, not users.id[1]. Query object references(*) are what seem ... read »
May 23, 2013 at 9:55 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Dan, According to the CF Admin, I'm running Java "1.6.0_45". As far as the DB column, in the database it's an INT. I'll see if I can dig into what CF sees it as. @WebManWalking, But h ... read »
May 23, 2013 at 9:49 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, I think the problem is that we're used to loose typing in ColdFusion, like JavaScript. If a value is a number but it's needed in an expression to be a string, noooo problem. I've encountered ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools