user460114
user460114

Reputation: 1848

CFHTTP issue connecting to XML file

I have the following xml, which is contained in a file named Inventory4zeroone.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Flexquery>
  <QueryName>Ecommerce Inventory</QueryName>
  <Data>
    <Item>
      <Web>1</Web>
      <productID>8203291034586124284</productID>
      <item_SID></item_SID>
      <categoryID>MC</categoryID>
      <title>SWOOSH RND FRT HOOD WHITE LRG</title>
      <description>Great Product</description>
      <price>34.5</price>
      <qty>17</qty>
      <image>8203291034586124284.jpg</image>
      <thumb>8203291034586124284_t.jpg</thumb>
      <active>1</active>
      <updatedDate>3/18/2013 11:31:41 AM</updatedDate>
    </Item>
    <Item>
      <Web>1</Web>
      <productID>8203291034586124285</productID>
      <item_SID></item_SID>
      <categoryID>MC</categoryID>
      <title>ACME RND FRT HOOD WHITE LRG</title>
      <description>Great Product</description>
      <price>49.2</price>
      <qty>19</qty>
      <image>8603291034586124284.jpg</image>
      <thumb>8603291034586124284_t.jpg</thumb>
      <active>1</active>
      <updatedDate>3/18/2013 11:31:41 AM</updatedDate>
    </Item>
  </Data>
</Flexquery>

I can browse to this directly at http://www.scrapbookcentral.co.nz/xml/inventory4zeroone.xml.

However, when I tried to fetch this file via CFHTTP as follows:

<cfhttp url="http://www.scrapbookcentral.co.nz/xml/inventory4zeroone.xml" 
        method="GET" 
        resolveurl="yes">

I get the following error:

enter image description here

You can view this happening at http://www.scrapbookcentral.co.nz/tasks/rpImportInventory.cfm

I found a site with a solution to the "Unable to determine MIME type of file" part of the error, so I changed the call to:

<cfhttp url="http://www.scrapbookcentral.co.nz/xml/inventory4zeroone.xml" 
        method="GET" 
        resolveurl="yes">
    <cfhttpparam type="header" name="mimetype" value="application/xml" />
</cfhttp>

That didn't work. Exactly the same error occurs.

So, I read other sites saying it might be a firewall issue. However, our systems admin says there are no firewall issues access these files.

So, I'm currently at a loss and would appreciate any assistance.

Upvotes: 0

Views: 2997

Answers (2)

barnyr
barnyr

Reputation: 5678

I think @Lucas is right, it's likely a network issue. If you want to confirm this, then install fiddler (http://fiddler2.com/) and add proxyServer="computer.running.fiddler" and proxyPort="8888" to the cfhttp call.

You can then compare the request headers your browser and CF are using. You can use the composer tab to edit and re-run the request CF made. One by one, copy the headers from the browser's request into the CF one and re-try it. At some point it'll start workign and you'll have found the header you need to change.

Upvotes: 0

Lucas
Lucas

Reputation: 1402

It must be your network.

Try running your code here http://cflive.net/ - it works fine.

I've run this:

<cfhttp url="http://www.scrapbookcentral.co.nz/xml/inventory4zeroone.xml" method="GET" result="myResult">
<cfhttpparam type="header" name="mimetype" value="application/xml" />
</cfhttp>
<cfdump var="#myResult#">

And all worked fine. I'd just drop the resolveurl bit and maybe add userAgent as some servers are set not to allow connections from non-browsers.

Upvotes: 2

Related Questions