Question

I am trying to implement a Server/Client communication with WCF and have stumbled accross duplex communication, but as I see it you would need a Server and 2 clients and only the 2 clients can communicate over the server with each other?!?

Is there a way to only get a 2 machines/process communication with WCF? So that the client communicates directly with the Server?

What I have done so far:

Create Project with contains the Interfaces, Classes, OperationContract/ServiceContract/ServiceBehaviour

Create Project which is the "Server" its basically just this code:

static void Main(string[] args)
{
    using (var serviceHost = new ServiceHost(typeof(ServiceInbound)))
    {
        // Open the host and start listening for incoming messages.
        serviceHost.Open();
        // Keep the service running until the Enter key is pressed.
        Console.WriteLine("The service is ready.");
        Console.WriteLine("Press the Enter key to terminate service.");
        Console.ReadLine();
    }
}

<system.serviceModel>
  <services>
    <service name="WCFLibary.ServiceInbound" behaviorConfiguration="WCFLibaryMEXBehavior">
      <endpoint address="service" binding="wsDualHttpBinding" contract="WCFLibary.IServiceInbound"/>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8080/WCFServer_Service"/>
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="WCFLibaryMEXBehavior">
        <serviceMetadata httpGetEnabled="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Create a client Project and in there Add a ServiceReference to the server localhost:8080/WCFServer_Service

I actually dont need a 2nd second client, I just want to push data between the server/client.

Was it helpful?

Solution

What your looking for is client callbacks. The client provides a callback function with the service call.

See this page on MSDN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top