[OperationContract]
[WebGet(UriTemplate = "/searchresults/{searchTerm}/{searchType}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
Message GetSearchResults(string searchTerm, string searchType);
[OperationContract]
[WebGet(UriTemplate = "/searchresults/{searchTerm}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
Message GetSearchResults(string searchTerm);
Is this possible - if not, can someone suggest an alternative?
I've found that this was the best solution for me:
[OperationContract(Name = "SearchresultsWithSearchType")]
[WebGet(UriTemplate = "/searchresults/{searchTerm}/{searchType=null}",
ResponseFormat = WebMessageFormat.Xml)]
Message GetSearchResults(string searchTerm, string searchType);
[OperationContract(Name = "SearchresultsWithoutSearchType")]
[WebGet(UriTemplate = "/searchresults/{searchTerm}",
ResponseFormat = WebMessageFormat.Xml)]
Message GetSearchResults(string searchTerm);
this matches:
"http://myservice/searchresults/mysearchterm"
"http://myservice/searchresults/mysearchterm/"
"http://myservice/searchresults/mysearchterm/mysearchtype"