C# 具有多操作合约的WCF Rest服务

C# 具有多操作合约的WCF Rest服务,c#,rest,wcf,C#,Rest,Wcf,我想用这样的操作契约创建WCF Rest服务 public interface ICustomerService { [OperationContract] [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetAllCustomer/")]

我想用这样的操作契约创建WCF Rest服务

public interface ICustomerService  
{  
    [OperationContract]
    [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,  
            ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetAllCustomer/")]  
    List<CustomerDataContract> GetAllCustomer();  

    [OperationContract]
    [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,  
            ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetSTOCK/ABC")]  
    List<CustomerDataContract> GetSTOCK();  

    [OperationContract]
    [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,  
            ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GETSUPINFO/XYZ/ABC")]  
    List<CustomerDataContract> GETSUPINFO();   
} 
公共接口ICCustomerService
{  
[经营合同]
[WebInvoke(Method=“GET”,RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json,UriTemplate=“/GetAllCustomer/”)
列出GetAllCustomer();
[经营合同]
[WebInvoke(Method=“GET”,RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json,UriTemplate=“/GetSTOCK/ABC”)]
List GetSTOCK();
[经营合同]
[WebInvoke(Method=“GET”,RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json,UriTemplate=“/GETSUPINFO/XYZ/ABC”)]
List GETSUPINFO();
} 

有人能帮忙吗?

有两种方法可以让Restful服务协议支持您的逻辑。第一个是更改您的WCF服务,您可以参考以下链接了解更多详细信息。

更简单的方法是用WepAPI包装您的逻辑,让您的WCF服务保持原样。您还可以从以下关于WebAPI的链接获得更多信息


您面临的问题是什么?只有您告诉我们您需要什么帮助,我们才能帮助您。您是否面临任何错误/问题?对于Filst URI来说很好,但是对于第二个和第三个端点,却找不到为什么在GET api中有/ABC&/XYZ/ABC?如果您想传递值以获取api-那么您的UriTemplate是错误的,应该是/{ABC}。。。还可以为ABC的相关数据类型的方法添加一个参数