Programming4us
         
 
 
Windows

SOA with .NET and Windows Azure: WCF Extensions - WCF Router (part 1) - The RoutingService Class & Routing Contracts

1/20/2011 7:58:50 PM
With WCF the service consumer sends a message to the service using a generated proxy. Both the service consumer and service rely on a compatible configuration that is shared between them.

Decoupling services from service consumers has several benefits, including the ability to independently leverage non-functional features, such as message-logging, security logic, fault tolerance, and various forms of routing processing.

Although building a router service was possible with .NET 3.5, version 4.0 of the .NET framework provides the WCF Router, an intermediary that can be configured as a service or service agent to receive and forward messages to target services based on various factors.

The WCF Router can be configured as an active or passive intermediary. An active WCF routing service can provide a range of runtime processing, such as security, message encoding, reliable sessions, and protocol compatibility. As a passive intermediary (meaning the router logic can alter policies and protocols, but not message structure or content), it can perform various forms of runtime routing logic, such as content-based routing, rules-based routing, and load-balancing.

The RoutingService Class

The WCF Router is equipped with a built-in filtering mechanism that allows you to specify the criteria used to dynamically determine message paths. For example, a message may need to be routed based on action, an XPath query, or its actual content.

WCF provides the System.ServiceModel.RoutingService class, and as with any other WCF service, the routing service can be hosted in IIS/WAS or it can be self-hosted in a Windows application or a Windows service.

The following example shows the contents of a .svc file with directives for hosting RoutingService in IIS:

Example 1.
<%
@ServiceHost
Service="System.ServiceModel.Routing.RoutingService,
System.ServiceModel.Routing,
version=4.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
%>

This next example shows RoutingService in a self-hosted environment:

Example 2.
using (ServiceHost serviceHost =
new ServiceHost(typeof(RoutingService)))
{
try
{
serviceHost.Open();
Console.WriteLine
("Routing service running. Press <Enter> to exit");
Console.ReadLine();
serviceHost.Close();
}
catch(CommunicationException)
{
serviceHost.Abort();
}
}

Routing Contracts

The RoutingService class supports the routing of messages that are part of synchronous (request-response) data exchanges as well as asynchronous and request-response exchanges over duplex protocols. The router can also multicast these two message exchange types.

The generic routing contracts available in the System.ServiceModel.Routing namespace to configure the router are listed in Table 1.

Table 1. Interface routing contracts used for different routing options.
Routing ContractSupports
IRequestReplyRouterWCF Sessions: if present

Transactions: if present

Asynchronous Messages: no

Multicast: no
ISimplexDatagramRouterWCF Sessions: if present

Transactions: no

Asynchronous Messages: yes

Multicast: yes
ISimplexSessionRouterWCF Sessions: required

Transactions: no

Asynchronous Messages: yes

Multicast: yes
IDuplexSessionRouterWCF Sessions: required

Transactions: if present

Asynchronous Messages: yes

Multicast: yes

Each of these routing contracts supports a different set of message exchange patterns and channel properties. Consequently, you may have to set up different routing endpoints for a service contract if your contract’s operations are designed with different message exchange or transaction requirements.

Note

The RoutingService class supports the numerous SOAP-based WCF bindings (BasicHttpBinding, WSHttpBinding, NetTcpBinding, etc.); however, it does not support the WebHttpBinding for REST services. Routing logic for REST services can be implemented with IIS Modules for Application Request Routing and UrlRewrite.

Other -----------------
- Windows 7: Accessing Shared Network Resources
- Windows 7: Managing Wireless Network Connections (part 4) - Creating User-Specific Wireless Connections
- Windows 7: Managing Wireless Network Connections (part 3) - Reordering Wireless Connections
- Windows 7: Managing Wireless Network Connections (part 2) - Working with Wireless Connection Properties
- Windows 7: Managing Wireless Network Connections (part 1) - Creating an Ad Hoc Wireless Network
- Windows7: Managing Network Connections (part 5) - Using a Network Connection to Wake Up a Sleeping Computer
- Windows7: Managing Network Connections (part 4) - Finding a Connection’s MAC Address
- Windows7: Managing Network Connections (part 3) - Setting Up a Static IP Address
- Windows7: Managing Network Connections (part 2) - Enabling Automatic IP Addressing
- Windows7: Managing Network Connections (part 1)
- Working with Windows 7’s Basic Network Tools and Tasks (part 6) - Customizing Your Network
- Working with Windows 7’s Basic Network Tools and Tasks (part 5) - Viewing Network Status Details
- Working with Windows 7’s Basic Network Tools and Tasks (part 4) - Displaying a Network Map
- Working with Windows 7’s Basic Network Tools and Tasks (part 3) - Viewing Network Computers and Devices
- Working with Windows 7’s Basic Network Tools and Tasks (part 2) - Setting Up a Homegroup
- Working with Windows 7’s Basic Network Tools and Tasks (part 1) - Accessing the Network and Sharing Center
- Windows 7: Setting Up a Peer-to-Peer Network (part 2) - Connecting to a Wireless Network
- Windows 7: Setting Up a Peer-to-Peer Network (part 1) - Changing the Computer and Workgroup Name
- Windows Vista: IE Security Features
- Windows 7: Troubleshooting Wireless Network Problems
 
 
Most View
- Sharepoint 2010 : Creating a .NET Connector in Visual Studio 2010 (part 1)
- Exchange Server 2010 Mailbox Services Configuration (part 4) - Client Configuration
- Windows Firewall with Advanced Security in Windows Server 2008 (part 3)
- Configuring Exchange Server 2003 to Coexist with X.400-Compliant Messaging Systems
- Troubleshooting Windows Home Server 2011 : Troubleshooting Device Problems
- Windows Azure : Programming Access Control Service (part 9) - Configuring a Web Service Client to Acquire and Send SAML Tokens
- Deploying ASP.NET 4 Applications with Visual Studio (part 2) - Copying a Website and Publishing a Website
- Windows Small Business Server 2011 : Deploying Network Printers (part 1) - Creating a Printer - Installing a Local Printer Manually
- Microsoft Dynamics AX 2009 : Working with Forms - Storing last form values
- Windows Phone 7 : Synching Notes to the Web
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS