本文介绍了是否可以保留然后将WCF消息转发到目标服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力的目标是拥有一个WCF路由服务,该服务可以接收来自客户端的消息,将它们持久保存到某种类型的数据存储中,然后将其处理/发送到其目标WCF服务。

The goal I'm working toward is having a WCF routing service that can receive messages from clients, persist them to some type of data store, and then process/send them to their destination WCF services.

注意事项:


  • 您可以使用(概述和)

  • ClientViaBehavior无法与basicHttpBinding一起使用,因此我需要使用wsHttpBinding(basicHttpBinding不会在消息,很难找到)

  • WCF消息对象本身被发送到路由服务,在该处可以将它作为序列化的字符串保存下来

  • 我不要路由服务以了解消息中的内容-因此,该服务将不会引用所涉及的数据合同

  • 当需要将消息路由到其目的地时,我需要能够在路由服务和目标服务之间创建通道

  • 路由服务并不了解每个目标服务是理想的-理想情况下,WCF可以基于动态创建适当的通道关于正在处理的消息的内容/标题。

  • You can create a routing service by using the ClientViaBehavior (outlined here and here)
  • The ClientViaBehavior will not work with basicHttpBinding, so I need to use wsHttpBinding (basicHttpBinding doesn't set the "To" header on the message, found out the hard way)
  • The WCF Message object itself is sent to the Routing Service, where it can be persisted as a serialized string
  • I don't want the Routing Service to know what's in the message - consequently, the service will not have a reference to the Data Contracts involved
  • When the time comes to route the Message to its destination, I need to be able to create a channel between the Routing Service and the Destination Service
  • It is not desirable for the Routing Service to be aware of each destination service - ideally, WCF could create the proper channel dynamically based on the content/headers of the message being processed.

WCF要求太多了吗? (我觉得这可能是...)

Is this too much to ask of WCF? (I have a feeling it might be...)

任何有关如何实现这种目标的建议都会受到赞赏。

Any advice on how to accomplish something like this would be appreciated.

推荐答案

如果您使用的是.NET 4(或可以移动到它),则WCF 4.0引入了自己的RoutingService基础结构。

If you're on .NET 4 (or can move to it), WCF 4.0 has introduced a RoutingService infrastructure of its own.

在重新发明轮子之前先检查一下!

Check it out, before you re-invent the wheel!

请参见的详细介绍,以了解WCF 4中的新功能(包括RoutingService)

See A Developer's Introduction to Windows Communication Foundation 4 for a great general intro to the new features (including RoutingService) in WCF 4

这篇关于是否可以保留然后将WCF消息转发到目标服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 13:49