5 Replies Latest reply: Jun 4, 2009 12:25 PM by ilssac RSS

    CFHTTP problem - is file-type extension required

    malletheadjw

      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>agent s_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

        • 1. Re: CFHTTP problem - is file-type extension required
          ilssac Community Member

          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.

          • 2. Re: CFHTTP problem - is file-type extension required
            malletheadjw Community Member

            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

            • 3. Re: CFHTTP problem - is file-type extension required
              JR "Bob" Dobbs-qSBHQ2 Community Member

              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.

              • 4. Re: CFHTTP problem - is file-type extension required
                malletheadjw Community Member

                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

                • 5. Re: CFHTTP problem - is file-type extension required
                  ilssac Community Member

                  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"?