Tag: uritemplate

WCF中的URITemplate中可选的查询string参数?

我正在WCF 4.0中开发一些RESTful服务。 我有一个方法如下: [OperationContract] [WebGet(UriTemplate = "Test?format=XML&records={records}", ResponseFormat=WebMessageFormat.Xml)] public string TestXml(string records) { return "Hello XML"; } 所以,如果我浏览浏览器到http:// localhost:8000 / Service / Test?format = XML&records = 10 ,那么所有东西都按预期工作。 但是,我希望能够导航到http:// localhost:8000 / Service / Test?format = XML,并离开URL的“&records = 10”部分。 但是现在,由于URI与预期的URI模板不匹配,我得到一个服务错误。 那么如何实现一些我的查询string参数的默认值? 我想默认的“logging”为10例如,如果该部分被closures查询string。