我编写了一个简单的应用程序来测试 RESTful API(由会计应用程序提供)。我已经在 Firefox 中安装了“Poster”来测试“GET 和 POST”XML,并且 API 的行为正常。我编写了一个简单的“GET”测试页面来从测试 CF8 应用程序中调用 API,API 返回了我预期的结果。我无法从测试 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="UTF8" 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 版本的!感谢任何最新的帮助。
最佳答案
来自评论
当使用 <cfhttp>
收到连接失败时,我首先尝试的是是为了验证您是否可以使用浏览器从您的 ColdFusion 服务器 导航到该 URL。如果该请求不起作用,那么它也不会通过 ColdFusion 调用起作用。在继续之前先解决该问题。
使用 SSL (HTTPS) 连接到安全站点时的另一个常见问题是 ColdFusion (Java) 不信任或不知道该证书。在这些情况下,您需要将他们的证书导入到用于 ColdFusion 的 Java keystore 中。
关于rest - CFHTTP HTTPS 连接失败 CF8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26158982/