【发布时间】:2018-05-10 00:52:17
【问题描述】:
我想像这样使用 Operation Contract 创建 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();
}
有人可以帮忙吗?
【问题讨论】:
-
你遇到了什么问题?
-
只有在您告诉我们您需要什么帮助时,我们才能为您提供帮助。您是否面临任何错误/问题?
-
它对于 Filst URI 工作正常,但对于第二个和第三个 End Point Not found
-
为什么在 GET api 中有 /ABC 和 /XYZ/ABC?如果您想将值传递给 GET api - 那么您的 UriTemplate 是错误的,应该是 /{ABC}... 还要在 ABC 的相关数据类型的方法中添加一个参数