【问题标题】:RouteTable Routes, Make my own proxy?RouteTable Routes,制作我自己的代理?
【发布时间】:2013-03-31 09:20:18
【问题描述】:

我喜欢控制并知道发生了什么,我也喜欢在我的网络服务中没有任何扩展名 (.svc)。所以我没有在我的Web.config 中定义任何端点。我使用RouteTable 类来添加Routes。像这些:

        RouteTable.Routes.Add(
            new ServiceRoute(@"Default",
                new CustomWebServiceHostFactory(),
                typeof(DefaultService)));
        RouteTable.Routes.Add(
            new ServiceRoute(@"Customer",
                new CustomWebServiceHostFactory(),
                typeof(CustomerService)));

我尝试像这样在客户端消费

_defaultService = new ChannelFactory<IDefaultContract>(
new BasicHttpBinding(), new EndpointAddress(@"http://myWeb.com/Default/")).CreateChannel();

我收到错误:“没有端点正在监听...”
使用浏览器,我可以调用任何操作(myWeb.com/Default/ReturnBool 返回 true)

【问题讨论】:

    标签: c# wcf


    【解决方案1】:

    已在CustomWebServiceHostFactory 中添加了BasicHttpBinding ServiceEndpoint,现在如果合同可用,我可以将服务作为客户端使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-12
      • 1970-01-01
      • 2012-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-28
      相关资源
      最近更新 更多