开发者

Restful WCF Default values

lyDefinition of the resource

[OperationContract]
[WebGet(UriTemplate = "getbydaterange/{insId}/{startDate}/{endDate}", ResponseFormat = WebMessageFormat.Json)]
List<RestfulServiceObj> GetMyObjectsByDateRange(string insId, string startDate, string endDate);

How can i make the last two parameters optional? i.e, I want the bottom three calls 开发者_开发百科to work

"http://domain.com/service.svc/myid/"

"http://domain.com/service.svc/myid/07-07-2011"

"http://domain.com/service.svc/myid/01-01-2011/07-08-2011"

But only the last call works, the rest give a missing parameter error.

Thanks Bullish


I believe you do so that same way you overload method calls:

[OperationContract]
[WebGet(UriTemplate = "getbydaterange/{insId}", ResponseFormat = WebMessageFormat.Json)]
List<RestfulServiceObj> GetMyObjectsByDateRange(string insId);

[OperationContract]
[WebGet(UriTemplate = "getbydaterange/{insId}/{startDate}", ResponseFormat = WebMessageFormat.Json)]
List<RestfulServiceObj> GetMyObjectsByDateRange(string insId, string startDate);

[OperationContract]
[WebGet(UriTemplate = "getbydaterange/{insId}/{startDate}/{endDate}", ResponseFormat = WebMessageFormat.Json)]
List<RestfulServiceObj> GetMyObjectsByDateRange(string insId, string startDate, string endDate);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜