2012-05-21 34 views
0

我有一个WCF REST服务与德下列网址:HTTP :/本地主机/ GetAllOrdersWCF休息URITemplate自动添加

但factorychannel总是genereates开放的到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被添加两次?

回答

0

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

Uri address = new Uri(“http:/localhost/Service.svc/”);