问题描述
我创建了RESTful服务,下面是代码。我想为这种方法支持不同的uri。请建议我怎么做。
支持的网址格式:
GET / [lCode] /国家/ [cCode |全部] /地理代码/ [地理代码]
GET /国家/ [cCode |全部] /地理代码/ [地理代码]
GET /国家?.. 。
POST /国家
以下是该方法的代码
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Xml,Method =GET,UriTemplate =/ Country /?cCode = {cCode}&+geographicCode = {geographicCode}&+lCode = {lCode}&iInactive = {iInactive})]
响应国家(字符串cCode,字符串geographicCode,
字符串lCode,字符串iInactive);
I have created the RESTful service and below is the code. I want to support different uri's for this method. Please suggest me how to do this.
Supported URL Patterns:
GET /[lCode]/Country/[cCode|All]/GeographicCode/[geographicCode]
GET /Country/[cCode|All]/GeographicCode/[geographicCode]
GET /Country?...
POST /Country
Below is the code for the method
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Xml, Method = "GET", UriTemplate = "/Country/?cCode={cCode}&" + "geographicCode={geographicCode}&" + "lCode={lCode}&iInactive={iInactive}")]
Response Country(string cCode, string geographicCode,
string lCode, string iInactive);
推荐答案
这篇关于在RESTful方法中支持多个uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!