0

我有一个带有以下 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 吗?

4

1 回答 1

0

Uri 是错误的 - 它应该是服务的 Uri。你应该写:

uri地址 = new Uri("http:/localhost/Service.svc/");

于 2012-05-23T12:54:59.763 回答