2015-05-11 69 views
1

我在調用REST服務時遇到問題。它總是返回NOT FOUND錯誤。Coldfusion REST服務未找到錯誤

REST服務註冊在CF管理員:

  • 根路徑:d:\項目\ 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中,阿帕奇2.4,CF 11開發版

感謝您的任何想法

EDIT1:

我有一個入口在hosts文件中。

127.0.0.1 testcf11.localhost 
+0

這似乎是問題與主機名相關聯。你有沒有在'test'文件中輸入'testcf11.localhost'?嘗試添加它,它可能會解決問題。 – Pankaj

+0

轉到'Administrator'並刷新您創建的其餘服務。然後再試一次。 – Pankaj

+0

休息服務被刷新。仍未找到錯誤 – user3601366

回答

0

問題出在港口。如果其他URL包含端口8500,則一切正常。

+0

我忘記了你正在使用Apache,內置的服務器。如果您使用IIS,則80是默認端口,您不需要將端口號添加到該URL。在我的情況下,它是IIS,所以它的工作。 – Pankaj

0

看起來問題似乎與hostname有關。你有沒有在你的hosts文件中輸入testcf11.localhost?嘗試添加它,它可能會解決問題。 hosts文件位於%windir%\system32\drivers\etc內。編輯文件並輸入與此類似的條目。

127.0.0.1 testcf11.localhost 

進入條目後,您可能需要重新啓動系統。 我檢查了我的系統,它的工作原理。

+0

是的,我在hosts文件中有一個條目。 – user3601366

相關問題