To manage mailing lists for clients and personal projects, I generally use Campaign Monitor. Its SOAP-based API has many different methods for subscribing, resubscribing, and unsubscribing email users to various client lists. The API interaction was great for a long time and then suddenly, a few weeks ago, I started getting "Connection Failure" on all of my ColdFusion CFHTTP requests.
I have no idea what the heck was going on. I could connect to the WSDL file just fine using the browser so I couldn't figure out why it was suddenly failing with ColdFusion's CFHTTP request. After a bit of Googling, I came across a post by Dan G. Switzer, II that discussed this very topic: CFHTTP "Connection Failures" issues with Gzip. In the post, Dan discussed that the problem comes from the fact that a connection failure in CFHTTP might be caused by the use of GZIP compression on the target server (which CFHTTP cannot handle).
I checked the compression in FireBug to confirm that this was, in fact, the case:
To fix this incompatibility, Dan gave a few different options. The one I ended up going with was passing in a no-compression CFHttpParam header value with my CFHTTP request:
<!--- Post SOAP data to campaign monitor. ---> <cfhttp url="......" method="get" result="objSOAPPost"> <cfhttpparam type="header" name="accept-encoding" value="no-compression" /> <!--- More params go here. ---> </cfhttp>
Adding that CFHttpParam did the trick! Thanks Dan!
Want to use code from this post? Check out the license.