首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在RESTful 8/Windows 2003/IIS6 6上尝试使用taffy框架时获得404

在RESTful 8/Windows 2003/IIS6 6上尝试使用taffy框架时获得404
EN

Stack Overflow用户
提问于 2013-05-17 19:12:59
回答 1查看 1.2K关注 0票数 3

我的任务是为我们的基于ColdFusion 8的CMS系统创建一个API。在进行了一些研究之后,我决定使用RESTful API是最好的选择,原因有三个:

  1. 它的右下角简单易用
  2. 相当容易实现
  3. 优良的长期解决方案

鉴于我首先是一个应用程序/系统程序员,高级web开发不是我的强项,所以我开始研究API的一些框架,而不是重新发明轮子。

我之所以决定使用太妃糖,主要是因为我发现它的设计比PowerNap和FW/1更优雅,但是在实现它时遇到了一些困难。

根据文档,我已经将解压缩的"taffy“文件夹放在我们的web根目录中,并在我们的开发站点中创建了一个api目录-

代码语言:javascript
复制
xxx.xxx.xxx.xxx/dev.cms/api_mk3

里面是目录:

代码语言:javascript
复制
/resources/studentCollection.cfc
/resources/studentMember.cfc
/Application.cfc
/index.cfm

所有四个文件的内容如下:

studentCollection.cfc

代码语言:javascript
复制
<cfscript>
component extends="taffy.core.resource" taffy:uri="/students" {
    public function get() {
        //query the database for matches, making use of optional parameter "eyeColor" if provided
        //then...
        var someCollectionObject = ArrayNew(1);
        someCollectionObject[1] = "Jason Bristol";
        return representationOf(someCollectionObject).withStatus(200); //collection might be query, array, etc
    }
}
</cfscript>

studentMember.cfc

代码语言:javascript
复制
<cfscript>
component extends="taffy.core.resource" taffy:uri="/students/{personName}" {
    public function get(string personName) {
        //find the requested person, by name
        //then...
        return noData().withStatus(404);//representationOf(personName).withStatus(200); //member might be a structure, ORM entity, etc
    }
}
</cfscript>

Application.cfc

代码语言:javascript
复制
<cfcomponent extends="taffy.core.api">
<cfscript>

    this.name = 'CMS-API';

    variables.framework = {};
    variables.framework.debugKey = "debug";
    variables.framework.reloadKey = "reload";
    variables.framework.reloadPassword = "true";
    variables.framework.representationClass = "taffy.core.genericRepresentation";
    variables.framework.returnExceptionsAsJson = true;

    // do your onApplicationStart stuff here
    function applicationStartEvent() {
    }

    // do your onRequestStart stuff here
    function requestStartEvent() {
    }

    // this function is called after the request has been parsed and all request details are known
    function onTaffyRequest(verb, cfc, requestArguments, mimeExt) {
        // this would be a good place for you to check API key validity and other non-resource-specific validation
        return true;
    }

</cfscript>

index.cfm

代码语言:javascript
复制
Blank, as per the documentation.

我遇到的问题是如果我要导航到

代码语言:javascript
复制
xxx.xxx.xxx.xxx/dev.cms/api_mk3/index.cfm/students

我会得到404

代码语言:javascript
复制
[14:57:02.963] GET http://xxx.xxx.xxx.xxx/dev.cms/api_mk3/index.cfm/students [HTTP/1.1 404 Not Found 56ms]

Request URL:
http://xxx.xxx.xxx.xxx/dev.cms/api_mk3/index.cfm/students


Request Method:
GET


Status Code:
HTTP/1.1 404 Not Found



Request Headers
14:57:02.000

User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Host:xxx.xxx.xxx.xxx
Connection:keep-alive
Accept-Language:en-US,en;q=0.5
Accept-Encoding:gzip, deflate
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8


Sent Cookie
CFTOKEN:85979056CFID:1194857



Response Headers
Δ56ms

X-Powered-By:ASP.NETServer:Microsoft-IIS/6.0
Date:Fri, 17 May 2013 18:57:37 GMT
Content-Type:text/html; charset=UTF-8
Connection:close

现在假设我正确理解了一切,我应该有一个.json格式的响应"Jason“或类似的东西。

我怀疑IIS6中的MIME类型或URL重写存在问题,但我不知道如何纠正这个问题。我推动升级到Windows 2008 RC2已经有一段时间了,但没有运气。

这个操作符是错误的还是可修复的?

编辑:--从我所能看到的内容来看,我在CF日志中什么也没有得到。下面是IIS日志中的条目:

代码语言:javascript
复制
2013-05-20 13:56:20 W3SVC4 10.40.204.236 GET /dev.cms/api_mk3/index.cfm/students - 80 - 70.88.47.65 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.31+(KHTML,+like+Gecko)+Chrome/26.0.1410.64+Safari/537.31 404 0 0
EN

回答 1

Stack Overflow用户

发布于 2013-05-17 19:24:59

这是:

代码语言:javascript
复制
xxx.xxx.xxx.xxx/dev.cms/api_mk3/index.cfm/students

看起来不像一个有效的网址。index.cfm是一个网页,所以在它之后添加目录是没有意义的。如果学生是子文件夹,您需要这样的内容:

代码语言:javascript
复制
xxx.xxx.xxx.xxx/dev.cms/api_mk3/students

如果该文件夹中有索引或默认文件,则应该会出现。否则,您必须在该文件夹中指定一个文件。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16616318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档