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);
精彩评论