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

CFHTTP Connection Failure

Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Hi,

I've been struggling with reading a 3rd party product feed.

I'm using the following code


<cfhttp url="http://webservices....">

<cfhttpparam type="header" name="accept-encoding" value="deflate;q=0">

<cfhttpparam type="header" name="te" value="deflate;q=0">

</cfhttp>




<cfdump var="#cfhttp#">

It returns with

struct
Charsetutf-8
ErrorDetail[empty string]
FilecontentConnection Failure
HeaderHTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Date: Sat, 18 Feb 2012 13:42:00 GMT Cache-Control: private, max-age=0 X-AspNet-Version: 4.0.30319 Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET
Mimetypetext/xml
Responseheader
struct
Cache-Controlprivate, max-age=0
Content-Typetext/xml; charset=utf-8
DateSat, 18 Feb 2012 13:42:00 GMT
ExplanationOK
Http_VersionHTTP/1.1
ServerMicrosoft-IIS/7.0
Status_Code200
X-AspNet-Version4.0.30319
X-Powered-ByASP.NET
Statuscode200 OK
TextYES

If use Firefox Live Headers plugin and view the feed in the browser, it displays fine and also the plugin gives me the information

GET /services/products.asmx...... HTTP/1.1

Host: webservices.......

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-gb,en;q=0.5

Accept-Encoding: gzip, deflate

Connection: keep-alive

Cache-Control: max-age=0

HTTP/1.1 200 OK

Cache-Control: private, max-age=0

Content-Type: text/xml; charset=utf-8

Content-Encoding: deflate

Server: Microsoft-IIS/7.0

X-AspNet-Version: 4.0.30319

X-Powered-By: ASP.NET

Date: Sat, 18 Feb 2012 13:34:09 GMT

Content-Length: 9225

I've googled and tried variation of accept-encoding to no avail, I just get connection failure.

Any ideas? Thanks

p.s. also tried

<cfhttpparam type="header" name="accept-encoding" value="no-compression"/>

TOPICS
Advanced techniques , Connector

Views

10.0K

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
Guide ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Have you tried with no headers at all? Can you browse the webservice from the ColdFusion server?  It seems a little odd that it's getting a 200 but giving you back "Connection Failure" - that would imply it's something in their software that's throwing that message rather than the HTTP transaction.

Is there any documentation that says what you need to send?

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
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Tried without httpheaders, the same result.

Added throwonerror and it gives the error "Connection Failure: Status Code Unavailable"

I haven't got access to the ColdFusion server, however I tried it on another CF server to the same affect. I'll install the developer edition on my local PC and retry.

I will see if I can find any documentation.

Thanks

--

Tested on local PC with CF9 dev server, same issue.

Documentation does not suggest anything that might help.

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
Community Expert ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

I agree with Owain. The combination of a 200 OK status and cfhttp.filecontent of 'Connection Failure' implies you got a response back, and the response had the message 'Connection Failure' as its only content.

The content-type is XML, which raises the question, is the service expecting your request to be SOAP?  Could we have a look at your cfhttp code?

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
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Well it appears to accept SOAP or HTTP requests.

That last dump was product of this code

cfsavecontent variable="soapBody">

<Cfoutput>

<?xml version="1.0" encoding="utf-8"?>

<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">

  <soap12:Body>

    <GetCategoryList xmlns="http://xxxx.com/">

      <apiKey>xxxx</apiKey>

      <clientID>xxxx</clientID>

    </GetCategoryList>

  </soap12:Body>

</soap12:Envelope>

</cfoutput>

</cfsavecontent>

 

 

<cfhttp url="http://webservices.xxxx.com/services/products.asmx"

method="post" result="httpResponse">

aram

type="header"

name="SOAPAction"

value="http://webservices.xxxx.com/services/products.asmx/GetCategoryList"

/>

<cfhttpparam

type="header"

name="accept-encoding"

value="no-compression"

/>

<cfhttpparam

type="xml"

value="#trim( soapBody )#"

/>

</cfhttp>

          <cfdump var="#httpResponse#">

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
Community Expert ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

LATEST

It is usually important to have no characters between the cfsavecontent tag and the XML declaration. Here follows the solution to a similar webservice problem in this forum:

<!--- WSDL --->

<cfset wsdl_url="http://dwc-dreiman-w7e/WSExchangeMeetingRooms/exchange.asmx?WSDL">

       

<cftry>

    <!--- Compose SOAP message to send to Web Service--->

    <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>

         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

             <soapenv:Body>

                 <ns:requestParameterName soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="http://your_own_namespace_url">

                        <c xsi:type="xsd:string">bkbk</c>

                      <d xsi:type="xsd:string">test message from bkbk</d>

                  </ns:requestParameterName>

              </soapenv:Body>

          </soapenv:Envelope>

    </cfsavecontent>

        <!--- Invoke web service to send message--->

        <cfhttp url="#wsdl_url#" method="post" >

            <cfhttpparam type="header" name="content-type" value="text/xml">

            <cfhttpparam type="header" name="SOAPAction" value="">

            <cfhttpparam type="header" name="content-length" value="#len(soap)#">

            <cfhttpparam type="header" name="charset" value="utf-8">

            <cfhttpparam type="xml" name="message" value="#trim(soap)#">

        </cfhttp>

        <p><cfoutput>#xmlFormat(cfhttp.fileContent)#</cfoutput> </p>

      

    <cfcatch type="any">

        <cfdump var="#cfcatch#">

    </cfcatch>

</cftry>

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
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

I might have been approaching it wrong, it is a SOAP webservice - so I'm going to try this

http://www.bennadel.com/blog/1809-Making-SOAP-Web-Service-Requests-With-ColdFusion-And-CFHTTP.htm

well actually it supports http requests, soap 1.1 and soap 1.2

even with trying the soap approach I get

struct
Charsetutf-8
ErrorDetail[empty string]
FilecontentConnection Failure
HeaderHTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Date: Sat, 18 Feb 2012 15:01:56 GMT Cache-Control: private, max-age=0 X-AspNet-Version: 4.0.30319 Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET
Mimetypeapplication/soap+xml
Responseheader
struct
Cache-Controlprivate, max-age=0
Content-Typeapplication/soap+xml; charset=utf-8
DateSat, 18 Feb 2012 15:01:56 GMT
ExplanationOK
Http_VersionHTTP/1.1
ServerMicrosoft-IIS/7.0
Status_Code200
X-AspNet-Version4.0.30319
X-Powered-ByASP.NET
Statuscode200 OK
TextYES

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