0

I have generated a webservice client (Service Reference) from a wsdl file provided by a web service. This webservice runs on 2 (or more) machines. What I like to do is to call from a single client (a windows service) both machines in a round robin fashion. If one of the webservices is offline the client should automatically choose the other instance.

The app.config file is very simple:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="MyServicePortBinding" messageEncoding="Mtom"/>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://server:8080/myservice/services" binding="basicHttpBinding"
            bindingConfiguration="MyServicePortBinding" contract="Service.MyService"
            name="MyServicePort1"  />
    </client>      
</system.serviceModel>

What I tried is to add a second endpoint to the configuration. This does fail with the exception: System.InvalidOperationException: An endpoint configuration section for contract 'Service.MyService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

Do you have any ideas how to set up a simple wcf loadbalancing mechanism on the client side?

Cheers

Fabian

Edit: This is not a duplicate to the linked question. The question here is how to implement a client based loadbalancing, not what happens if I put in 2 endpoints. This was only what I came up with.

Fabian Lang
  • 78
  • 1
  • 8
  • Load balancing is normally done on the server not the client. – Aiden Grossman Oct 05 '16 at 13:32
  • I agree, but it is not possible for me to use a loadbalancer on the server. I could only install a loadbalancer on one server which would be a single point of failure. – Fabian Lang Oct 05 '16 at 13:38
  • You may find relief using dynamic endpoints, e.g. placing hostname's in app.config and doing something like [this](http://stackoverflow.com/questions/12209610/dynamically-set-endpoint-address-in-wcf-client-with-net-tcp-binding) – RamblinRose Oct 05 '16 at 13:42
  • The solution in @RamblinRose comment was to dynamically change the url in my own code. I thought more of [link](http://www.codeproject.com/Articles/778575/WCF-Routing-Service-Part-III-Failover-Load-Balanci), but without the need of an extra project for the virtual endpoint/router. – Fabian Lang Oct 06 '16 at 05:07

0 Answers0