我编写了一个简单的应用程序来测试一个 RESTful API(由一个会计应用程序提供)。我在 Firefox 中安装了“Poster”来测试“GET 和 POST”XML,并且 API 的行为正常。我编写了一个简单的“GET”测试页面来从测试 CF8 应用程序中调用 API,并且 API 返回了我预期的结果。我无法从测试 CF8 应用程序中 POST。
我已将以下内容插入到我的 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 版本更老!任何最新的帮助表示赞赏。