WS Dual Http

The Dual Http sample demonstrates how to configure the WSDualHttpBinding binding. This sample consists of a client console program (.exe) and a service library (.dll) hosted by Internet Information Services (IIS). The service implements a duplex contract. The contract is defined by the ICalculatorDuplex interface, which exposes math operations (Add, Subtract, Multiply, and Divide). In this sample, the ICalculatorDuplex interface allows the client to perform math operations, calculating a running result over the session. Independently, the service returns results on the ICalculatorDuplexCallback interface. A duplex contract requires a session, because a context must be established to correlate the set of messages being sent between client and service. The WSDualHttpBinding binding supports duplex communication.


The setup procedure and build instructions for this sample are located at the end of this topic.


The samples may already be installed on your machine. Check for the following (default) directory before continuing.


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.


To configure a service endpoint with the WSDualHttpBinding, specify the binding in the endpoint configuration as shown.

<endpoint address=""  
         contract="Microsoft.ServiceModel.Samples.ICalculatorDuplex" />  

On the client, you must configure an address that the server can use to connect to the client as shown in the following sample configuration.

    <endpoint address=  
         contract="Microsoft.ServiceModel.Samples.ICalculatorDuplex" />  

    <!-- Configure a WSDualHttpBinding that supports duplex -->  
    <!-- communication. -->  
      <binding name="Binding1"  

When you run the sample, the operation requests and responses are displayed in the client console window. Press ENTER in the client window to shut down the client.

Press <ENTER> to terminate client once the output is displayed.  

Equation(0 + 100 - 50 * 17.65 / 2 = 441.25)  

When you run the sample, you see the messages returned to the client on the callback interface sent from the service. Each intermediate result is displayed, followed by the entire equation upon completion of all operations. Press ENTER to shut down the client.

To set up, build, and run the sample

  1. Install ASP.NET 4.0 using the following command.

    %windir%\Microsoft.NET\Framework\v4.0.XXXXX\aspnet_regiis.exe /i /enable  
  2. Ensure that you have performed the One-Time Setup Procedure for the Windows Communication Foundation Samples.

  3. To build the C# or Visual Basic .NET edition of the solution, follow the instructions in Building the Windows Communication Foundation Samples.

  4. To run the sample in a single- or cross-machine configuration, follow the instructions in Running the Windows Communication Foundation Samples.


    When running the client in a cross-machine configuration, be sure to replace localhost in both the address attribute of the endpoint element and the clientBaseAddress attribute of the <binding> element of the <wsDualHttpBinding> element with the name of the appropriate machine, as shown:

        <endpoint name = ""  
        <binding name="DuplexBinding" clientBaseAddress=  

See Also