RouteTable 路由,制作我自己的代理? [英] RouteTable Routes, Make my own proxy?

查看:29
本文介绍了RouteTable 路由,制作我自己的代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I like to have control and know what happend, also i like to dont have any extension (.svc) inside my webservice. So i don't define any endpoints inside my Web.config. I use the RouteTable class to add Routes. Like these :

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

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

I try consume on the client side like these

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

我收到错误消息:没有端点侦听..."
使用浏览器,我可以调用任何操作(myWeb.com/Default/ReturnBool 返回 true)

I get the error: "There was no endpoint listening at..."
With the browser i can call any operation (myWeb.com/Default/ReturnBool returns true)

推荐答案

CustomWebServiceHostFactory 中添加了一个 BasicHttpBinding ServiceEndpoint,现在我可以使用该服务作为客户端,如果合同可用.

Have added a BasicHttpBinding ServiceEndpoint inside CustomWebServiceHostFactory, now i can consume the service as client if the contract is available.

这篇关于RouteTable 路由,制作我自己的代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆