【问题标题】:WCF rest the URITemplate added automaticallyWCF rest 自动添加的 URITemplate
【发布时间】:2012-05-28 00:55:42
【问题描述】:

我有一个带有以下 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 会被添加两次吗?

【问题讨论】:

    标签: wcf-rest


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 2013-04-16
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 2013-07-24
      相关资源
      最近更新 更多