Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

WS-Addressing and WCF

When defining an endpoint for a WCF service, the "address" attribute (in case of defining it in a configuration file) is the logical address. The logical address corrsponds to the "To" header defined in WS-Addressing. Default WCF uses the same address as the physical address, but the physical address can be set individually in the "listenUri" attribute. The physical address corrsponds to the "Via" header defined in WS-Addressing. The logical address is important when WCF should dispatch the incoming message, because default it requires an exact match between the "To" header in the message and the "address" attribute. As most part of WCF this is possible to change by configuring WCF to use another message filter (which could be a custom written or one included in WCF).

Normally when using WCF this is nothing that developers need to think about, but this is important to know if we want to put something in between the service consumer and the service, for example a router or a tool like TcpTrace. So if we want to add a router to the architecture it is necessary to ensure that the service consumer and the service still uses the same logical address. It is possible to configure the "listenUri" for the service with the physical address of the router, and when a service consumer adds a reference to the service it will automatically be correctly configured. Normally I wouldn't recommend doing this, because there is really no need for the service to know about the existense of a router or not. Besides the router might only be needed for some service consumers, but not for others (for example service consumers existing in DMZ verses service consumers on the LAN). To configure the service consumer manually is straightforward since all that is needed is to add the ClientViaBehavior, which could be done both in code and configuration.

<behaviors>
  <endpointBehaviors>
    <behavior name="Default">
      <clientVia viaUri="http://localhost:8010/RouterService.svc"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

I recommend reading Aaron Skonnard's Service Station column "WCF addressing in depth" in June 2007 issue of MSDN Magazine for a more fully explanation of this topic. Aaron covers mostly the service part of the story, but does so in great depth. Michele Bustamante (dasBlonde, thatindigogirl) has two nice articles about WCF routing in the April and June 2008 issues of MSDN Magazine that I also recommend reading.

Published den 4 juli 2008 17:44 by ericqu
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Venky said:

Nice blog
oktober 19, 2010 05:39

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems