Hi
This is my first post so please be gentle with me.
I want to develop a generic template for processing WCF messages; one where message interrogation, validation, tracing etc happens through the use of pluggable components. To this end, I want to have intermediary nodes process messages and forward them onto other services.
I don't think that's a strange scenario.
It looks to me - from a beginner's viewpoint - that I want to use the viaUri behaviour to pass the message on transparently; without the calling service knowing anything other than the endpoint. Is this correct
All the examples I've seen thus far use an HTTP endpoint - is this a pre-requisite We initially planned to use MSMQ as the transport layer but I am now beginning to think that the intermediary pattern built in to WCF is for synchronous processing - is this correct or is it just a lack of samples
Thanks for any help or direction you can give me.
Ciaran

viaUri
Jim815
Thanks for the code, I'll try that now.
Apologies for the "Config" mistake, it is a red herring: I did that to make the line shorter! Honest.
Ciaran
JT Snake
Hi
I assume you intend you use message contracts and peek at the message headers for your routing scenario. If you intend to use data contracts, you may want to look into the IExtensibleDataObject interface.
Most samples for WCF tend to use either basicHttpBinding or wsHttpBinding, since those two are either very common or very simple to analyze (you can peek at the message, unlike with tcp binding).
Here is a blog post regarding viaUri:
http://www.winterdom.com/weblog/2006/04/17/RedirectingThroughTcpTraceWithWSEAndWCF.aspx
You can also create a service on “any free port”:
http://kennyw.com/indigo/104
http://kennyw.com/indigo/117
And here is a scenario which may be similar to yours:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=374307&SiteID=1
davherb
Adiavn, thanks for the reply.
I've replied to Scott's post below; can you have a look at the further detail and see if you can pinpoint where I am going wrong
As you can see from the example I have posted, I use the ChannelFactory to create a channel; everything is driven from the config. I am quite happy to change that, if needed, but I don't know how to jump to the Redirecting example you posted.....
For my MSMQ work, I don't have a proxy class.... That's why the HTTP examples are confusing the issue for me, I think.
Ciaran
psique
I'm also looking at msmq in an intermediary scenario and would like to implement a dynamic address lookup (i.e. the intermediary looks in some kind of central repository for the physical address of a logical name supplied by the client).
Is anyone able to confirm the following (apologies if this is nonsense, i'm fairly new to WCF and messaging) :-
1> I cannot specify a logical name for an endpoint used by msmq
2> The viaUri is ignored for msmq bindings
On the client i have the following
NetMsmqBinding binding = new NetMsmqBinding();
binding.Security.Mode = NetMsmqSecurityMode.None;
EndpointAddress endPointAddress = new EndpointAddress("urn:TestService");
ChannelFactory<ITestService> channelFactory = new ChannelFactory<ITestService>(binding, endPointAddress);
Uri Via = new Uri("net.msmq://localhost/private/intermediary");
channelFactory.Endpoint.Behaviors.Add(new ViaUriBehavior(Via));
proxy = channelFactory.CreateChannel();
proxy.TestOperation("test");
If i run this code i get a runtime exception stating that this is an invalid scheme for this binding (parameter uri). Which i'm assuming is because the NetMsmq binding only supports the net.msmq uri scheme. This makes it impossible to supply a logical name for a service
If i change the endpoint address code and supply a physical address then the message doesn't appear to be sent via the physical address supplied in the via Uri. i.e. for an Endpoint address of net.msmq://localhost/private/testservice, the message goes straight to that queue and not the net.msmq://localhost/private/intermediary queue.
Any help would be most appreciated.
Damian
Mike81
There seems to be a mismatch between your code and configuration.
Try changing
internalMessage =
new ChannelFactory<IInboundMessageContract>("Config").CreateChannel();
to
internalMessage =
new ChannelFactory<IInboundMessageContract>("Intermediary").CreateChannel();
Regarding the redirecting example, to set the viaUri in code (and not configuration) you need to change the code a little:
ChannelFactory<IInboundMessageContract> cf = new ChannelFactory<IInboundMessageContract>("Config");
TypeInfoServiceContractProxy proxy = new TypeInfoServiceContractProxy();
Uri tcpTraceUri = new Uri(http://localhost:8080/TypeInfo);
cf.Endpoint.Behaviors.Add(new ViaUriBehavior(tcpTraceUri));
internalMessage = cf.CreateChannel();
Amer 570
Scott
Thanks for the reply. I've sent you an email directly asking for the router sample.
I've tried using a viaUri with an Uri for an MSMQ endpoint but it doesn't seem to work! My config is below.
<client>
<endpoint name="Intermediary"
address="net.msmq://localhost/private/InternalMessageProcessing"
contract="Contracts.External.IInboundMessageContract"
binding="netMsmqBinding"
bindingConfiguration="QueuedBinding"
behaviorConfiguration="Test" />
</client>
<behaviors>
<behavior name="Test">
<channelViaUri viaUri="net.msmq://localhost/private/TestQueueOne"/>
</behavior>
</behaviors>
The message appears on InternalMessageProcessing but not TestQueueOne.
I create my Channel this way:
internalMessage =
new ChannelFactory<IInboundMessageContract>("Config").CreateChannel();
Should I be doing this some other way
Also, am I right to think that in this scenario, a well defined endpoint from the client could be a purely logical endpoint - because the MessageHeader could be cracked open and the To replaced. WCF doesn't try and route to the initial endpoint if you have changed the address, does it In fact, does WCF do anything implicitly when that message is delivered or does it just fire-and-forget
Thanks in advance,
Ciaran
Tiadd4
Good data.
It is not required to use http. While I have not personally used msmq myself, I have used tcp and namedpipes in a router scenario.
The client will need to know the final endpoint address of the server (logical name) as well as the physical address (via) of the router. Once it gets to the router you can route it however you wish. It can be dependent on some header value or a round robin load balancer or read from some routing database (or xml file) or whatever.
I have a simple router sample that I'm trying to get onto windowscommunication.net but hasn't made it there yet. If you want to see it go ahead and email me at smason@microsoft.com.
Thanks!
Scott