我有一个带有以下 URL 的 WCF REST 服务:http://localhost/GetAllOrders
但是 factorychannel 总是将 Uri 生成到 http:/localhost/Service.svc/GetAllOrders/GetAllOrders
这是我的客户工厂频道:
Uri address = new Uri("http:/localhost/Service.svc/GetAllOrders");
var factory = new System.ServiceModel.Web.WebChannelFactory<App.WebService.IOrderSvc>(address);
var webHttpBinding = factory.Endpoint.Binding as System.ServiceModel.WebHttpBinding;
App.WebService.IOrderSvc service = factory.CreateChannel();
var orders = service.GetAll(); // this one throwing an error since the URI has become http:/localhost/Service.svc/GetAllOrders/GetAllOrders
这是服务合同:
[WebGet(UriTemplate = "GetAllOrders")]
[OperationContract]
List<Order> GetAll();
知道为什么要添加两次 Uritemplate 吗?