如何在回调方向扩展WCF?
我可以使用行为将 IParameterInspector 附加到 ClientRuntime 中的每个操作以及服务端 DispatchRuntime 中的每个操作。但似乎这只适用于从客户端到服务。
我还希望能够在从服务到客户端的回调中附加一个 IParameterInspector,如上所述,但我找不到任何可扩展点来执行此操作。
有什么想法吗?
I can attach an IParameterInspector using behaviors to each operation in the ClientRuntime and also to each operation in the DispatchRuntime on the service side. But it seems this only works from client to service.
I also want to be able to attach an IParameterInspector in the callbacks from service to client on both sides of the wire as above but I can't find any extensibility points to do this.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有点晦涩难懂,并且似乎没有详细记录,但您可以使用标准 WCF 行为功能来自定义两端。
在客户端,这个属性会让它发生。
只需将此属性应用于实现回调接口的类即可。
在服务器上,事情变得有点棘手。您需要通过 ApplyDispatchBehavior 进行连接。在本例中,我通过服务行为来完成此操作,但主体也适用于 OperationBehaviors 和 EndpointBehaviors。
同样,只需将此属性应用于您的服务实现,即可将参数检查器用于所有回调操作。
虽然这些示例演示了连接 IParameterInspector 实现,但所有其他 WCF 扩展点的相同方法可用于在客户端和服务器上自定义回调通道。
This is a little obscure and does not appear to be all that well documented but you can customise both ends using standard WCF behavior capabilities.
On the client, this attribute would make it happen.
Simply apply this attribute on the class that implements your callback interface.
On the server, it gets a little trickier. You need to hook up via the ApplyDispatchBehavior. In this case I have done it through a service behavior but the principal applies to OperationBehaviors and EndpointBehaviors as well.
Again, simply apply this attribute to your service implementation to have your parameter inspector utilised for all callback operations.
While these examples demonstrate hooking up IParameterInspector implementations, the same approach for all other WCF extension points can be used to customise callback channels at both the client and server.