WS Dual Http

Download sample

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.

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. Ensure that you have performed the One-Time Setup Procedure for the Windows Communication Foundation Samples.

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

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

    Note Note:

    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=
Footer image

Send comments about this topic to Microsoft.
© Microsoft Corporation. All rights reserved.

Community Additions