本文介绍了WCF - 实现方法重载“UriTemplateTable不支持多个模板”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行我的服务时发生以下错误



UriTemplateTable不支持多个具有与模板'/ TasteList等效路径的模板?TokenNo = { TokenNo}'但具有不同的查询字符串,其中查询字符串不能通过文字值消除歧义。有关详细信息,请参阅UriTemplateTable的文档。





代码如下:



when i am Execute my service below error occuring

UriTemplateTable does not support multiple templates that have equivalent path as template '/TasteList?TokenNo={TokenNo}' but have different query strings, where the query strings cannot all be disambiguated via literal values. See the documentation for UriTemplateTable for more detail.


the code are below :

[OperationContract(Name = "GetAllTaste")]
        [WebInvoke(Method = "GET", UriTemplate = "/TasteList?TokenNo={TokenNo}", BodyStyle = WebMessageBodyStyle.WrappedRequest,
                    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        TasteModel[] TasteList(string TokenNo);

        [OperationContract(Name = "GetClosestTaste")]
        [WebInvoke(Method = "GET", UriTemplate = "/TasteList?TokenNo={TokenNo}&Latitude={Latitude}&Longitude={Longitude}&Distanse={Distanse}", BodyStyle = WebMessageBodyStyle.WrappedRequest,
                    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        TasteModel[] TasteList(string TokenNo, string Latitude, string Longitude, string Distanse);

        [OperationContract(Name = "GetTasteByLocation")]
        [WebInvoke(Method = "GET", UriTemplate = "/TasteList?TokenNo={TokenNo}&EncryptedLocationID={EncryptedLocationID}", BodyStyle = WebMessageBodyStyle.WrappedRequest,
                    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        TasteModel[] TasteList(string TokenNo, string EncryptedLocationID);

        [OperationContract(Name = "TasteList")]
        [WebInvoke(Method = "GET", UriTemplate = "/TasteList?TokenNo={TokenNo}&EncryptedLocationID={EncryptedLocationID}&Latitude={Latitude}&Longitude={Longitude}&Distanse={Distanse}", BodyStyle = WebMessageBodyStyle.WrappedRequest,
                    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        TasteModel[] TasteList(string TokenNo, string EncryptedLocationID, string Latitude, string Longitude, string Distanse);

推荐答案

尝试更改<$的开头每个操作的c $ c> UriTemplate 指向适当的路径。 (而不是 / TasteList 使用: / GetAllTaste / GetClosestTaste 等等......)

Try to change the beginning of the UriTemplate of each operation to point to the appropriate path. (Instead of /TasteList use: /GetAllTaste, /GetClosestTaste, etc...)


[OperationContract(Name = "TasteList")]
        [WebInvoke(Method = "POST", UriTemplate = "/TasteList",
                   RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        TasteModel TasteList(TasteModel model);


这篇关于WCF - 实现方法重载“UriTemplateTable不支持多个模板”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:40