3

REST API は初めてです。更新されたサイト デザインで Web アプリケーションを REST-ful に変換しようとしています。

私の開発サーバーの作業環境は、Coldfusion10、Windows 2008 R2 サーバーです。これまでのところ、REST サービスを ColdFusion 10 サーバーの Web ルート ディレクトリに正常に登録し、正常に動作しています。

ただし、REST サービスをサイトのディレクトリに登録する必要があります。私はそうしましたが、数回は機能しましたが、ほとんどの場合、CFC を編集した後 (文字列をcfreturn「foo」から「foo2」に変更)、500 エラーが発生します。URL経由で直接アクセスしてCFCの構文を確認したところ、問題ありませんでした。管理者に REST サービスを追加しようとしましたが、ほとんどの場合、次のように管理者に追加するとエラーが発生します。

•Unable to refresh REST service.
Application rc could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs. 

Application.cfc に Web サービスを追加しました

<cfcomponent output="false">
  <cfset this.name = hash(getCurrentTemplatePath()) />
  <cfset this.applicationTimeout = createTimeSpan( 0, 0, 1, 0 ) />

  <cffunction name="onRequestStart" access="public" returntype="boolean" output="false" hint="I initialize the request.">
    <cfset restInitApplication("E:\flex\html\v4\rc","rc")>
    <cfreturn true />
  </cffunction>
</cfcomponent> 

これは /rc/studentHandler.cfc です

<cfcomponent restpath="student" rest="true">
  <cffunction name="getMethod" access="remote" output="false" returntype="string" httpmethod="get">
    <cfreturn "foo">
  </cffunction>
</cfcomponent> 

最後のファイルは、student.cfm です。から呼びますhttp://mydevip/v4/student.cfm

<cfhttp url="http://mydevip/rest/rc/student" method="get">
<cfoutput>#cfhttp.filecontent#</cfoutput> 

URL から直接 cfc を呼び出そうとしましたが、これは CF Web ルート フォルダー内の cfc の場合に機能http://mydevip/rest/rc/studentし、カスタム ディレクトリ内の cfc を呼び出すとエラーが発生します。

application.log からのエラーは次のとおりです。

"Error","ajp-bio-8012-exec-5","11/13/13","10:13:30","5C89BF4E37081433800CEF0D961170B0","object is not an instance of declaring class The specific sequence of files included or processed is: E:\flex\html\v4\rc\studentHandler.cfc'' " 

ありがとう、

ゲーナ

4

0 に答える 0