问题
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.
Things to consider:
- 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.
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.
回答1:
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!
See A Developer's Introduction to Windows Communication Foundation 4 for a great general intro to the new features (including RoutingService) in WCF 4
回答2:
Yes, you can make your routing service accepts any message.
This link should help you: Building a WCF Router, Part 1
来源:https://stackoverflow.com/questions/6887509/is-it-possible-to-persist-and-then-forward-wcf-messages-to-destination-services