public static MessageFilterTable <IEnumerable <ServiceEndpoint> > CreateFilterTable(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw FxTrace.Exception.ArgumentNullOrEmpty("name");
            }

            RoutingSection routingSection = (RoutingSection)ConfigurationManager.GetSection("system.serviceModel/routing");

            if (routingSection == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingSectionNotFound));
            }

            FilterTableEntryCollection routingTableElement = routingSection.FilterTables[name];

            if (routingTableElement == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingTableNotFound(name)));
            }
            XmlNamespaceManager xmlNamespaces = new XPathMessageContext();

            foreach (NamespaceElement nsElement in routingSection.NamespaceTable)
            {
                xmlNamespaces.AddNamespace(nsElement.Prefix, nsElement.Namespace);
            }

            FilterElementCollection filterElements = routingSection.Filters;
            MessageFilterTable <IEnumerable <ServiceEndpoint> > routingTable = new MessageFilterTable <IEnumerable <ServiceEndpoint> >();

            foreach (FilterTableEntryElement entry in routingTableElement)
            {
                FilterElement filterElement = filterElements[entry.FilterName];
                if (filterElement == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.FilterElementNotFound(entry.FilterName)));
                }
                MessageFilter filter = filterElement.CreateFilter(xmlNamespaces, filterElements);
                //retreive alternate service endpoints
                IList <ServiceEndpoint> endpoints = new List <ServiceEndpoint>();
                if (!string.IsNullOrEmpty(entry.BackupList))
                {
                    BackupEndpointCollection alternateEndpointListElement = routingSection.BackupLists[entry.BackupList];
                    if (alternateEndpointListElement == null)
                    {
                        throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.BackupListNotFound(entry.BackupList)));
                    }
                    endpoints = alternateEndpointListElement.CreateAlternateEndpoints();
                }
                //add first endpoint to beginning of list
                endpoints.Insert(0, ClientEndpointLoader.LoadEndpoint(entry.EndpointName));
                routingTable.Add(filter, endpoints, entry.Priority);
            }

            return(routingTable);
        }
        internal static string GetAddressingNamespace(AddressingVersion addressing)
        {
            string ns;

            if (addressing == AddressingVersion.WSAddressingAugust2004)
            {
                ns = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
            }
            else if (addressing == AddressingVersion.WSAddressing10)
            {
                ns = "http://www.w3.org/2005/08/addressing";
            }
            else if (addressing == AddressingVersion.None)
            {
                ns = "http://schemas.microsoft.com/ws/2005/05/addressing/none";
            }
            else
            {
                throw FxTrace.Exception.Argument("addressing", SR2.AddressingVersionInvalid(addressing.ToString()));
            }
            return(ns);
        }