In our previous discussion, we discussed about the concept of routing in WCF, using the router service. You can go through the article here.
Continuing on the same lines, we will now try to understand the EndPointName filter setting as the filter type to redirect the client request to the appropriate service. We will use the same service code that we used in the previous discussion and configure the same for the use of EndPointName filter.
To start with, we will change our Routing_Service_Host application configuration. To start with, we will update the BaseAddress of the service to the following:
- <host>
- <baseAddresses>
- <add baseAddress="http://localhost:5643"/>
- </baseAddresses>
- </host>
- <endpoint
- address="/Svc1"
- binding="wsHttpBinding"
- name="Service_1"
- contract="System.ServiceModel.Routing.IRequestReplyRouter"/>
- <endpoint
- address="/Svc2"
- binding="wsHttpBinding"
- name="Service_2"
- contract="System.ServiceModel.Routing.IRequestReplyRouter"/>
- <routing>
- <filters>
- <filter name="MyFilter" filterType="EndpointName" filterData="Service_1" />
- <filter name="MyFilter2" filterType="EndpointName" filterData="Service_2" />
- </filters>
- <filterTables>
- <filterTable name="ServiceRouterTable">
- <add filterName="MyFilter" endpointName="Service_1"/>
- <add filterName="MyFilter2" endpointName="Service_2"/>
- </filterTable>
- </filterTables>
- </routing>
- <client>
- <endpoint address="http://localhost:5643/Svc1" binding="wsHttpBinding"
- contract="ServiceReference1.IService1" name="routingSvcEndPoint_Svc1" />
- <endpoint address="http://localhost:5643/Svc2" binding="wsHttpBinding"
- contract="ServiceReference2.IService2" name="routingSvcEndPoint_Svc2" />
- </client>
How it works ?
Now let's try to understand how this filter works.
To start with when we call Service1 from the client application, the system picks up the address http://localhost:5643/Svc1 from the endpoints of client application config file and call the router service. At the router service host end, it matches it's endpoint from the config file and get its name property, which is Service_1. This endpoint name is matched with the filter MyFilter with filterData value Service_1. Based on this value, the client end point with this name is selected i.e. http://localhost:65145/Service1.svc is selected and the service is executed. Similarly, this is executed for the Service_2.

Pradeep SahooPosted May 18, 2016, 5:05 PM
Nice share .........
Amit DavePosted May 3, 2016, 10:34 AM
Keep up the Good work!
Sonu ChaudharyPosted May 2, 2016, 5:56 AM
Thanks for sharing
Thiruppathi RPosted May 2, 2016, 1:54 AM
Good Job..
Munesh SharmaPosted May 1, 2016, 1:40 PM
nice
Vijay KumarPosted May 1, 2016, 1:21 AM
Nice Article
Kuppurasu NagarajPosted Apr 30, 2016, 2:14 PM
Nice Sharing..
Rahul Kumar SaxenaPosted Apr 30, 2016, 1:48 PM
Good one
Rahul Kumar SaxenaPosted Apr 30, 2016, 1:48 PM
Good One
Vignesh ManiPosted Apr 30, 2016, 12:45 PM
Nice one