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

CFHTTP problem - is file-type extension required

New Here ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

Hello,

Running CF8 on Win2003/IIS. 

I have the following simple code to check a value from another server:

<cfhttp method="get" URL= "http://server.somewhere.com/websvc/util?a=doHTMLRequest&event=workgroupstat"   throwonerror="yes">

<cfset theContent = "#cfhttp.FileContent#">

<cfoutput>#theContent#</cfoutput>

I have also tried:

<cfhttp
  method="get"
  url="http://server.somewhere.com/websvc/util">  (with and without the ? after the word util)
  <cfhttpparam name="a" type="URL" value="doHTMLRequest">
  <cfhttpparam name="event" type="URL" value="workgroupstat">
</cfhttp>

The URL that is shown above returns nothing when using it within CFHTTP. If I change the URL to http://www.google.com or whatever I get the code of that page assigned to my theContent variable as expected 

From a browser, the URL used in the cfhttp function above works fine. The request returns a simple HTML file with the following code from which I need to pull the agents_available data:

<HTML><HEAD><TITLE>Agents Available</TITLE></HEAD><BODY><H2>workgroup:Chat</H2><H2>agents_available:1</H2><H2>agents_logged_in:1</H2></BODY></HTML>

I cannot understand why I can call any other page from the internet (and our network) and put it into my theContent variable but I can't call this one.  Could it be something in the structure of the URL??

I'm thinking that the CFHTTP function cannot properly format the request without the file-type extension.

Any ideas are appreciate.  Regards, Jerry

TOPICS
Advanced techniques

Views

3.8K

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
Valorous Hero ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

The two steps I would use to start analysing this problem.

1) Change the <cfhttp...> to use the throwonerror="no" AND redirect="no" parameters and then use <cfdump var="#cfhttp#"> afterword.

This should show you exactly what the server is returning to you for these request you are making, not just the content.

2) Do the request in a browser such as FireFox with the HTTP Headers plugin and look at all the content that is being sent between the browser and the server.  Look closely at any post, get and cookie headers that are being sent and then povide matching content in your <cfhttp...> tag.

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 ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

Hi Ian,

I tried your suggestions.  Used Firefox with FireBug and LiveHTTP Headers and nothing appears out of the ordinary except the Content-Length which is always 0.  It's not being redirected.  The response is 200 OK.

i.e.:

cfhttp.errorDetail: 
cfhttp.text:  YES
cfhttp.statusCode  200 OK
cfhttp.MIMEType  Unable to determine MIME type of file.
cfhttp.header  HTTP/1.1 200 OK Set-Cookie: JSESSIONID=88760F22E9FA8717DE807D6F1F758E9A; Path=/websvc Date: Thu, 04 Jun 2009 17:04:37 GMT Content-Length: 0 Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET

But when the URL is called directly from a browser the Content-Length is not 0.  It is 148 bytes.

I'm using:

<cfset Mokrynski.PageName = "_">

<cfsetting showdebugoutput="no">

<!---cfhttp   method="get"   url="http://server.somewhere.com/websvc/util">;  

<cfhttpparam name="a" type="URL" value="doHTMLRequest">  

<cfhttpparam name="event" type="URL" value="workgroupstat">

</cfhttp--->

<cfhttp   method="get"   url="http://server.somewhere.com/websvc/util?a=doHTMLRequest&event=workgroupstat" />

<cfset agentCount = (cfhttp.fileContent)>

<cfoutput>#agentCount#</cfoutput>

<cfoutput> <p>cfhttp.errorDetail:  #cfhttp.errorDetail#</p>

<p>cfhttp.text:  #cfhttp.text#</p>

<p>cfhttp.statusCode  #cfhttp.statusCode#</p>

<p>cfhttp.MIMEType  #cfhttp.MIMEType#</p>

<p>cfhttp.header  #cfhttp.header#</p>

</cfoutput>

Note that there are two methods I've used - 1 used commentd out in this code.  If i change the url in the cfhttp function to ANYTHING else I get the expected result - goog.com, our site, cnn.com, whomever but not from this URL which clearly works from a browser.

Thanks, Jerry

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
Advisor ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

Is it possible that the page at http://server.somewhere.com/websvc/util is user-agent aware and is treating requests from a web browser differently from requests from CFHTTP?  You might try providing a value for the useragent attribute of CFHTTP to mimic IE or Firefox's user agent string.

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 ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

Thanks for the hint. I've just tried:

  <cfhttp
  method="get"
  url="http://server.somewhere.com/websvc/util?a=doHTMLRequest&event=workgroupstat" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729;)" timeout="600">

and it didn't change anything.  I believe that this is a valid user-agent value.

I created a Scheduled Task to call the page and just save it as a file in the CF root directory and it comes back as empty as well.

I'm beginning to think it's in the setup of the web service - maybe an access setting like in cffunction where it is set to public, private, remote, etc.

I am truly baffled.

Jerry

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
Valorous Hero ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

LATEST

malletheadjw wrote:

I'm beginning to think it's in the setup of the web service - maybe an access setting like in cffunction where it is set to public, private, remote, etc.

I am truly baffled.

Jerry

That would not make much sense, if you can access it from a browser, then it is responding to remote requests.

I do not remember, is this web service on the internet or a local intranet?  If it is a local intranet is it perchance on an IIS web server configured to use "Integrated Windows Security"?

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