WCF 中具有多个合约的多个端点
您好,我有 2 个服务合约 IService1 和 IService2
我希望每个服务合约有不同的端点,而且我只想使用 basichttpbinding。
假设 IService1 地址是 http://localhost:4040/MyApp/Service1.svc 那么
我想使用地址 http://localhost:4040/MyApp/Service1.svc/service2 访问 IService2或使用 IService1 地址以外的地址
是否可能?
Hi I have 2 service contracts IService1 and IService2
I want different endpoints for each service contract also I want to use only basichttpbinding.
Suppose IService1 address is http://localhost:4040/MyApp/Service1.svc then
I want to access IService2 with address http://localhost:4040/MyApp/Service1.svc/service2 or with address other than IService1 address
Is it possible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在 IIS 中托管这个吗?如果是这样: IIS 规定了您的地址 - 它们被定义为
因此,如果您想要两个单独的地址,则需要两个单独的虚拟目录...
或者:自主机,那么您有完全的自由地址!
如果您自行托管,您绝对可以定义一个暴露两个端点的服务(在同一实现类中实现两个服务接口):
因此您的服务 1 可以在定义的基地址(
http://localhost: 4040/MyApp/Service1.svc
),而您的服务 2 将位于http://localhost:4040/MyApp/Service1.svc/Service2
。这就是你要找的吗?Are you hosting this in IIS ?? If so: IIS dictates your addresses - they're defined as
So if you want two separate addresses, you need two separate virtual directories....
Or: self-host, then you have full freedom of addresses!
If you self-host, you could definitely define a service (implementing both service interfaces in the same implementation class) that exposes two endpoints:
So your service 1 would be accessible at the base address defined (
http://localhost:4040/MyApp/Service1.svc
), while your service 2 would be athttp://localhost:4040/MyApp/Service1.svc/Service2
. Is that what you're looking for??