CFHTTP issues

(warning: cold fusion technospeak ahead)

So I’m developing an application that makes use of the eBay API. In this application, there is a need to send well-formatted xml to eBay. In addition, all requests must include certain HTTP Header information, so that eBay knows just who the hell is talking to them. Why is this a problem? well, in CFMX, you can send a type XML parameter via CFHTTP. The problem is that if you have a type XML parameter, you’re not allowed to send anything else (I’ve no idea why). So, why don’t I just send the XML as a formfield or something? Because I need to send the XML as content, not as a header. If I try and send it as type CGI, or URL, or FormField, or Cookie, I get no response back. Interestingly, if I send a .xml file (using type=”file”), I get a whole new error (bad developerID in the session certificate — but I’ve confirmed that it is indeed, valid, so I’ve no idea why I get that error). So it looks like I can’t use CFHTTP, which is really, really odd. So I’ve resorted to calling the Microsoft ServerHTTPXML COM Object, and using that. Which works just peachy, thanks.

Here’s the working code (where #string# is a properly formed XML document) (by the way, we’re not here to critique my naming conventions — these are temporary for a prototype):

<CFOBJECT action="Create" name="objSrvHTTP" class="MSXML2.ServerXMLHTTP">
<CFSETdummy=objSrvHTTP.open("POST","#request.targetURL#",false)>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-COMPATIBILITY-LEVEL","#request.CompatibilityLevel#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-SESSION-CERTIFICATE","#request.DevID#;#request.AppID#;#request.CertID#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-DEV-NAME","#request.DevID#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-APP-NAME","#request.AppID#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-CERT-NAME","#request.CertID#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-CALL-NAME","#attributes.CallName#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-SITEID","#request.siteID#")>
<CFSET dummy=objSrvHTTP.setRequestHeader("X-EBAY-API-DETAIL-LEVEL","#request.DetailLevel#")>
<CFSET dummy=objSrvHTTP.send("#ToString(string)#")>
<CFSET results=XMLParse(objSrvHTTP.responsetext)>

And here’s the non-working CFHTTP code:

<CFHTTP method="POST" url="#request.targetURL#" resolveurl="No" timeout="10" throwonerror="Yes">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-COMPATIBILITY-LEVEL" value="#request.CompatibilityLevel#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-SESSION-CERTIFICATE" value="#request.DevID#;#request.AppID#;#request.CertID#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-DEV-NAME" value="#request.DevID#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-APP-NAME" value="#request.AppID#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-CERT-NAME" value="#request.CertID#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-CALL-NAME" value="#attributes.CallName#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-SITEID" value="#request.siteID#">
<CFHTTPParam type="#variables.headerType#" name="X-EBAY-API-DETAIL-LEVEL" value="#request.DetailLevel#">
<CFHTTPParam type="FILE" name="xml" file="#request.filepath#test.xml">
</CFHTTP>
<CFSET results=XMLParse(cfhttp.filecontent)>

My question to the world is then: Is there a way to send content via CFHTTP? If you’re familiar with the eBay API, is there a reason why when I send an XML file via CFHTTP, it gives me nice error code in response, and when I send it in any other format, I get nothing back at all (and I know the DevID is right, because the COM object call works, using the same one).