gpt4 book ai didi

wcf - 是否有可能有 "overloaded"uritemplates?

转载 作者:行者123 更新时间:2023-12-04 06:48:59 25 4
gpt4 key购买 nike

        [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);

这是可能的 - 如果没有,有人可以提出替代方案吗?

最佳答案

我发现这对我来说是最好的解决方案:

    [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);

这匹配:
"http://myservice/searchresults/mysearchterm" "http://myservice/searchresults/mysearchterm/" "http://myservice/searchresults/mysearchterm/mysearchtype"

关于wcf - 是否有可能有 "overloaded"uritemplates?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3676005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com