找不到Coldfusion REST服务错误

时间:2015-05-11 17:35:57

标签: rest coldfusion

调用REST服务时遇到问题。它总是返回NOT FOUND错误。

REST服务在CF管理员中注册:

  • 根路径:D:\ projects \ testcf11 \ restfolder
  • 主持人:testcf11.localhost
  • 服务映射:testrest

在/ restfolder中是一个cf组件:

<cfcomponent rest="true" restpath="Customers">
<cffunction name="getCustomer" restpath="{customerID}" access="remote" returntype="String" httpmethod="GET">
    <cfargument name="customerID" required="true" restargsource="Path" type="numeric">
    <cfset ret = "Customer ID: " & arguments.customerID>
    <cfreturn ret>
</cffunction>
</cfcomponent>

我尝试使用该代码:

<cfhttp url="http://testcf11.localhost/rest/testrest/Customers/1" method="get">
</cfhttp>
<cfdump var="#cfhttp#" />

Softwer:Windows 8.1,Apache 2.4,CF 11 Developer Edition

感谢您的任何想法

EDIT1:

我在hosts文件中有一个条目。

127.0.0.1 testcf11.localhost

2 个答案:

答案 0 :(得分:0)

似乎问题与hostname有关。您是否在hosts的{​​{1}}文件中输入了一个条目?尝试添加它,它可以解决问题。 testcf11.localhost文件位于hosts内。编辑文件并输入与此类似的条目。

%windir%\system32\drivers\etc

进行输入后,您可能需要重新启动系统。 我在我的系统上查了一下它就可以了。

答案 1 :(得分:0)

问题出在港口。如果其余URL包含端口8500,则一切正常。