我设立一个REST端点,看起来像下面这样:为什么WCF 3.5 REST入门工具包会这样做?
[WebInvoke(Method = "POST", UriTemplate = "?format=json", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
和
[WebInvoke(Method = "DELETE", UriTemplate = "?token={token}&format=json", ResponseFormat = WebMessageFormat.Json)]
上述引发以下错误:
UriTemplateTable does not support '?format=json' and '?token={token}&format=json' since they are not equivalent, but cannot be disambiguated because they have equivalent paths and the same common literal values for the query string. See the documentation for UriTemplateTable for more detail.
我不是专家在WCF,但我会想象它应该首先由HTTP方法映射,然后由URI模板映射。它似乎是倒退。如果我的两个URI模板:
?token={token}&format=json
这工作,因为他们是等价的,它会出现看的HTTP方法,其中一个是POST,另一个是删除。
REST是否应该这样工作?为什么URI模板表不是首先被HTTP方法和URI模板排序?当1个HTTP方法需要一个参数,另一个不需要,或者如果我想要做可选参数(例如'format'参数未被传递,默认为XML),这可能会导致一些严重的挫折。
什么时候发生错误?在编译,启动和访问服务期间? – 2010-04-20 13:46:08
访问服务。 – Brandon 2010-04-20 21:17:41
使用什么访问?原始的HTTP请求(你自己构建它们,使用curl/whatever)?你不会碰巧使用Silverlight,是吗? – 2010-04-21 11:36:25