【问题标题】:REST WCF Service - Consume QueryString ParametersREST WCF 服务 - 使用 QueryString 参数
【发布时间】:2011-07-22 20:18:40
【问题描述】:

我有这个 REST WCF 服务。

[WebInvoke(UriTemplate = "/GetNames/{Category}?order=asc", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
public List<Names> GetNames(string Category)
{
    //Code to retrieve Names by category.
}

Category 参数映射到 Uri 中的{Category}

但是如何将 Uri 中的订单查询字符串映射到这个方法呢?

将订单添加为参数方法不起作用。

请帮忙。提前致谢。

【问题讨论】:

  • 如果您发布代码、XML 或数据示例,在文本编辑器中突出显示这些行,然后单击编辑器上的“代码示例”按钮 ({ })工具栏以很好地格式化和语法突出显示它!如果您发布错误消息,使用块引号 (` " ` ) 正确格式化错误消息。

标签: parameters wcf-rest uritemplate


【解决方案1】:

您是否尝试过 - 在 Uritemplate 和函数中使用“/GetNames/{Category}?order={ordering}”

public List<Names> GetNames(string Category, string ordering)
{
  //Code to retrieve Names by category.
}

【讨论】:

    猜你喜欢
    • 2020-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-21
    • 2012-01-07
    • 2013-01-24
    相关资源
    最近更新 更多