2014-10-02 94 views
0

我編寫了一個簡單的應用程序來測試RESTful API(由會計應用程序提供)。我已經在Firefox中安裝了「Poster」來測試「GET和POST」XML,並且API的行爲應該與它應該一樣。我編寫了一個簡單的「GET」測試頁面,從測試CF8應用程序中調用API,API返回了我期望的結果。我無法從測試CF8應用程序中進行POST。CFHTTP HTTPS連接失敗CF8

我已插入以下到我的application.cfm:

<!--- fix for HTTPS connection failures ---> 
<cfif NOT isDefined("Application.sslfix")> 
    <cfset objSecurity = createObject("java", "java.security.Security") /> 
    <cfset objSecurity.removeProvider("JsafeJCE") /> 
    <cfset Application.sslfix = true /> 
</cfif> 

這是一個錯誤的代碼:

<cfprocessingdirective suppressWhiteSpace = "Yes">  
    <cfxml variable="customerxml"> 
     <?xml version="1.0" encoding="UTF­8" standalone="yes"?> 
     <dataentry> 
      <interface name="Customer Edit"></interface> 
      <entity> 
       <attribute name="Customer Code">REP003</attribute> 
       <attribute name="Customer Name">Repsol3</attribute> 
       <attribute name="Address Line 1">El House</attribute> 
       <attribute name="Address Line 2">El Street</attribute> 
       <attribute name="Address Line 3">El Town</attribute> 
      </entity> 
     </dataentry> 
    </cfxml> 
</cfprocessingdirective> 

<cfhttp 
    method="post" 
    url="https://***/wsapi/1.1/dataentry/" 
    username="***" 
    password="***" 
    charset="utf-8"> 
    <cfhttpparam type="header" name="Accept-Encoding" value="*" /> 
    <cfhttpparam type="header" name="TE" value="deflate;q=0" /> 
    <cfhttpparam type="header" name="Content-Type" value="application/xml" /> 
    <cfhttpparam name="XML_Test" type="xml" value="#customerxml#"> 
</cfhttp> 

有關於這一主題發表了很多,我已經試過最多的事但其中一些帖子是關於甚至比我的舊CF版本!任何最新的幫助表示讚賞。

+2

爲什麼要刪除JsafeJCE安全提供程序?我認爲這不會有幫助。最可能的問題是您需要將SSL證書導入到服務器的Java密鑰庫中。我已經概述了[這個其他答案]中的步驟(http://stackoverflow.com/a/20475763/1636917)。 – 2014-10-02 11:50:17

+0

你能發佈實際的迴應/錯誤嗎? – Nebu 2014-10-02 12:21:44

+0

要驗證的另一件事是您可以打開瀏覽器並連接到來自ColdFusion server_的URL _。 – 2014-10-02 12:45:23

回答

2

從評論

,我接收使用<cfhttp>是驗證您可以使用瀏覽器從ColdFusion服務器導航到URL連接失敗時嘗試的第一件事。如果該請求不起作用,那麼ColdFusion調用也無法工作。在繼續之前先解決該問題。

使用SSL(HTTPS)連接到安全站點時的另一個常見問題是該證書不受信任,或者ColdFusion(Java)未知。在這些情況下,您需要將他們的證書導入到用於ColdFusion的Java密鑰庫中。