将范围添加到公告端点
我目前正在实现一项使用 WCF 发现 并提供发现端点的服务和公告端点。我还需要使用范围来过滤客户端上已宣布/发现的端点。
将范围添加到发现端点效果很好,但我无法找出公告端点的正确配置。这是我的想法:
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDiscovery>
<announcementEndpoints>
<endpoint kind="udpAnnouncementEndpoint"
behaviorConfiguration="DiscoveryBehavior" />
</announcementEndpoints>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="DiscoveryBehavior">
<endpointDiscovery>
<scopes>
<add scope="http://My/Scope"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
我认为这是不正确的,因为我重用了为发现端点创建的端点行为。但这是我发现描述我的范围的唯一方式。
我认为使用公告范围应该是可能的,因为:
- 没有其他方法来过滤收到的公告
EndpointDiscoveryMetadata
类(我在收到公告时获得的实例)包含一个属性 范围。
但根据我的配置,客户端的 Scopes 集合对于除 mex 端点之外的所有端点都是空的(其中有两个 tempuri 范围)。
那么,有什么想法可以正确声明公告端点的范围吗? 任何帮助将不胜感激,非常感谢。
I'm currently implementing a service that uses WCF discovery and provides Discovery Endpoint and Announcement Endpoint. I also need to use scopes in order to filter announced/discovered endpoints on my client.
Adding scopes to the Discovery Endpoint works great, but I can't figure out the right configuration for Announcement Endpoint. Here's what I came up with:
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDiscovery>
<announcementEndpoints>
<endpoint kind="udpAnnouncementEndpoint"
behaviorConfiguration="DiscoveryBehavior" />
</announcementEndpoints>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="DiscoveryBehavior">
<endpointDiscovery>
<scopes>
<add scope="http://My/Scope"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
I suppose it's not correct because I reuse the endpoint behavior that I created for my Discovery Endpoint. But that's the only way I found to describe my scopes.
I think that using scopes for announcements should be possible because:
- There is no other way to filter received announcements
- The
EndpointDiscoveryMetadata
class (the instance of which I get when announcements get received) contains a property Scopes.
But with my configuration the Scopes
collection on client side is empty for all endpoints except the mex one (it has two tempuri scopes in it).
So, any ideas how to correctly declare scopes for the announcement endpoints?
Any help will be appreciated, many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我自己就弄清楚了(嗯,在 来自 MSDN 的配置示例的帮助下 我之前没有找到)。
关键是将 DiscoveryBehavior 应用到所有可发现的服务端点,而不是公告端点。
所以,
这有效,我在客户端得到了我的范围。我希望它能帮助某人。
Actually, just figured it out myself (well, with help of Configuration sample from MSDN that I didn't find earlier).
The key is to apply DiscoveryBehavior to all discoverable service endpoints rather than to an announcement endpoint.
So,
This works and I get my scopes at client side. I hope it helps someone.