1 out of 1 rated this helpful - Rate this topic

Hello World with the Routing Service

This sample demonstrates the Windows Communication Foundation (WCF) Routing Service. The Routing Service is a WCF component that makes it easy to include a content-based router in your application. This sample adapts the standard WCF Calculator Sample to communicate using the Routing Service. In this sample, the Calculator client is configured to send messages to an endpoint exposed by the router. The Routing Service is configured to accept all messages sent to it and to forward them to an endpoint that corresponds to the Calculator service. Thus messages sent from the client are received by the router and re-routed to the actual Calculator service. Messages from the Calculator service are sent back to the router, which in turn passes them back to the Calculator client.

To use this sample

  1. Using Visual Studio 2010, open HelloRoutingService.sln.

  2. Press F5 or CTRL+SHIFT+B.

    Dd795218.note(en-us,VS.100).gifNote:
    If you press F5, the Calculator Client automatically starts. If you press CTRL+SHIFT+B (build), you must start following applications yourself.

    1. Calculator client (./CalculatorClient/bin/client.exe

    2. Calculator service (./CalculatorService/bin/service.exe)

    3. Routing service (./RoutingService/bin/RoutingService.exe)

  3. Press ENTER to start the client.

    You should see the following output:

    Add(100,15.99) = 115.99

    Subtract(145,76.54) = 68.46

    Multiply(9,81.25) = 731.25

    Divide(22,7) = 3.14285714285714

Configurable via Code or App.Config

The sample ships configured to use an App.config file to define the router’s behavior. You can also change the name of the App.config file to something else so that it is not recognized and uncomment the method call to ConfigureRouterViaCode(). Either method results in the same behavior from the router.

Scenario

This sample demonstrates the router acting as a basic message pump. The routing service acts as a transparent proxy node configured to pass messages directly to a preconfigured set of destination endpoints.

Real World Scenario

Contoso wants to increase the flexibility it has in the naming, addressing, configuration, and security of its services. To do this, they place a basic message pump in front of their services to act as a public facing endpoint. This allows them to place additional security in front of their actual services and make it easier to implement scaled out solutions or service versioning at a later date.

Dd795218.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WCF\Basic\RoutingServices\HelloRoutingService

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Running Sample Files using Multiple Startup Projects
You don't need to create batch file to run them as Chakravarthy mentioned. You can do it  by just setting up Multiple Startup Projects. (Right-click on a solution, then select Set Startup Project.
Running Sample Files
The given solution consists all the required files. But you can't run all the projects when you run from the Visual Studio with the F5 button. So, you have to run them from the command prompt with the mentioned sequence. Hence, you could write a batch file to run them. The batch file might consists the commands like the below mentioned

First Step: Open the command prompt and run the following command. This will open a notepad for you. Make sure that you are running the below command from the path where the solution file is located. Usually, the solution would be at <<ExtractedFilesPath>>\WF_WCF_Samples\WCF\Basic\RoutingServices\HelloRoutingService\CS\

> notepad runsamples.cmd

Second Step: Paste the following statements within that file and close with save.

start CalculatorClient\bin\client.exe
start CalculatorService\bin\service.exe
start RoutingService\bin\RoutingService.exe

Step Three: At the command prompt run the file that you have just created
>runsamples.cmd

Final Result : Now, you could see all the apps ready for demo