Tuesday, April 13, 2010

WCF 4.0 Routing Service – Protocol Bridging

Today Microsoft Released VS.NET 2010 and .NET 4.0 this release also includes WCF 4.0 .  In this release WCF 4.0 has many new features like

  • Simple Configuration
  • Router Service
  • Serialization Enhancements
  • Web Programming
  • Service Discovery
  • Workflow Service.

In this blog post We are going to look at  WCF 4.o Routing Service- Protocol bridging. 

Protocol Bridging is basically transport conversion. for example the below picture shows that the client sends a message to  Routing Service via HTTP protocol once message reaches to Routing Service now routing service will route the same message to backend WCF Service via  TCP/IP protocol. Here we are bridging the protocols between  HTTP and TCP/IP.

image  

For the demo purpose I am going to Create WCF service  and self hosting in Console application.

Now We need to create and host the following Services and client.

  1. WCF Service
  2. Routing Service
  3. WCF Client
  4. Test it

 

1) Creating WCF Service

Fire up VS.NET 2010 make sure that you have selected .NET Framework 4.0 and then select Console application project template  to create a new project name the project as SystemWCFService.

image

Now we need to add the imageAssembly References to the project. 

ServiceContract and operation contract definition

Here I am define three operations contracts .  GetProcess operations will select all process currently running on the server and returns to client.

image

  Service Implementation
image

Service Hosting

image

Service Configuration
image

 

[Note : In WCF 4.0 we can create a service with Simple configuration and we can use protocol mapping to override default endpoints]

 

2) Creating Routing Service

To create Routing service we need to add new console project[.NET Framework 4.0]  and add the following Assembly References to it.

image

Now we need to host our routing service for that we need  ABC  A- Address , B-Binding , C-Contract .   WCF 4.0 comes with the following Routing services Contracts . ISimplexDatagramRouter, ISimplexSessionRouter, IRequestReplyRouter, IDuplexSessionRouter our WCF service message  pattern is Request-Reply so we are going to host our Routing service with IRequestReplyRouter contract.

image

image

Define  FilterTable and Filters .

Now we need to Add the routing table and message filters. These are the settings used by the router service to do the actual routing of the messages

image

 

Now we need to define actual Service Endpoint inside Routing Service configuration file .

image

Here we need to specify  actual WCF service Endpoint and binding. actually routing service do not care about service contract that is why we put  *.

Hosting Routing Service


image

Routing Service listens an Endpoint which client expects.  [i.e http://localhost:9000/SystemRoutingService]

3) Creating WCF client & calling WCF Service

Here we are going to use ChannelFactroy class to create WCF proxy and invoke the Operations. for that we need  WCF Service binding , Endpoint & Contract.

Here Endpoint Address same as Routing Service EP.

image

Testing:

First execute the  WCF service and then Routing Service now run the client . Now  client calls GetProcess  method and receives  result from Actual WCF service via Routing service .

image

Next Blog post I will show how Routing service  Multicasting works.

Nandri(Thanks)

SreenivasaRagavan

3 comments:

Or Sedi said...

Hi
Thanks for the great article.

How do I call the call the routing service through xmlhttp request / ajax?

Thanks
Or

MaciejLisCK said...

Great article!

Leela Kumar said...

Hi ,This is greate and greate article.but I want this article project samples,
please provide me or send me this sample to my mail id :-cleelakumar@yahoo.co.in