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.
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.
- WCF Service
- Routing Service
- WCF Client
- 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.
Now we need to add the Assembly 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.
Service Implementation
Service Hosting
Service Configuration
[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.
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.
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
Now we need to define actual Service Endpoint inside Routing Service configuration file .
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
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.
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 .
Next Blog post I will show how Routing service Multicasting works.
Nandri(Thanks)
SreenivasaRagavan