The actual reply endpoint address for the service that receives the request message is embedded in a message header. Yes, a default address may already be defined in the configuration of the endpoint, but in our case it changes at runtime. There is one queue for the incoming messages to be processed by the service - and another queue for the service to send back e.g. status or report messages from which the client can get updates on where the service-side processing is at.
If I create a proxy like this:
new ChannelFactory<IOrderStatus>("MsmqClient");
IOrderStatus proxy = fac.CreateChannel();
The return endpoint address where to send the reply messages is hidden in a message header (materialized as a SOAP header on the wire). When reading this value from the header (more on this in another post) I need to be able to set the dynamically retrieved URI of the endpoint in my code. Hm, nothing really hard to do. Look here:
Ha, it is read-only as well... and now?
When investigating a bit further we dig out that we are able to repoint the endpoint URL of a proxy if it extends ClientBase, but you unfortunately we can't do it with IClientChannel.
The problem here is that proxies are bound to the channels when created. We cannot repurpose a proxy without creating a new repurposed channel underneath. However, we can modify the factory and get back a modified proxy to use.
new ChannelFactory<IOrderStatus>("MsmqClient");
IOrderStatus proxy = fac.CreateChannel();
// ... do the work you need to do ...
fac.Description.Endpoint.Address = new EndpointAddress("<my new address>");
proxy = fac.CreateChannel();
new ChannelFactory<IOrderStatus>("MsmqClient");
fac.Description.Endpoint.Address = new EndpointAddress("<my new address>");
IOrderStatus proxy = fac.CreateChannel();
A WCF proxy is a light-weight, fly-away beast - the channel is the heavy monster.
They really didn't intend to make messaging apps easy, did they?
Posted by: John Cavnar-Johnson | 01/07/2006 at 06:04 AM
Great info! I tried doing the same thing a while back using the ClientBase object. You can see this example here: http://blogs.thinktecture.com/cweyer/archive/2006/01/07/414354.aspx It's nice to know that there's another way of doing this without the need of a proxy.
Posted by: Javier G. Lozano | 01/07/2006 at 07:05 AM
I'm sorry, I posted the URL to your post, not mine. Here's the link in case you want to take a look at it: http://www.lozanotek.com/archive/2005/10/18/4305.aspx
Posted by: Javier G. Lozano | 01/07/2006 at 07:07 AM
I believe this is an ocean of knowledge, i really admire your article in your mind. You let me learn a lot from your blog. I wish you continue to update, i will continue to support your blog.
Posted by: nike air jordan | 06/02/2010 at 11:25 AM
Thanks so much for posting these, they are fantastic! So bummed I missed what looks like a truly unique evening.
Posted by: Jordans 6 | 07/08/2010 at 09:34 AM
So funny, I think.*
Posted by: coach outlet | 11/09/2010 at 07:34 AM
Jim Carrey will serve as the host of Saturday Night Live to kick off the 2011 shows. The Air Jordan Fusion 20 (AJF 20) Low White Silver Midnight Navy did decent with Jordan heads, but ultimately, they have hit discount prices.
Posted by: Michael Jordan Shoes | 12/29/2010 at 04:14 AM
he really didn't intend to make messaging apps easy, did he?
Posted by: freelance writing | 03/22/2011 at 01:04 PM