Manage multiple WCF endpoints for the same service

I am creating one application that uses WCF to call multiple external endpoints. All remote endpoints are identical except for the URI. I would like to consider them as a pool: add and delete endpoints through the configuration and ask the application to understand what to do.

My initial plan was to define one endoint in app.config, then iterate over my list of endpoints and update client.Endpoint.Address on the fly to point to the right place. Unfortunately, this property is read-only, which makes the plan inoperative.

I'm a little here. Any suggestions on how I can do this?

+5
source share
3 answers

How to create a service endpoint in code shows how to manage service endpoints in code, not configuration.

+1
source

Have you tried a separate name that is passed to the client’s constructor?

          <endpoint address="http://localhost:18000/MyService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                contract="MyServiceReference.IMyService" name="BasicHttpBinding_IMyService" />
          <endpoint address="http://localhost:18001/MyService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                contract="MyServiceReference.IMyService" name="MyService_Secondary" />
          <endpoint address="http://localhost:18002/MyService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                contract="MyServiceReference.IMyService" name="MyService_Tertiary" />
0
source

Store the endpoint addresses in the database table and use Jason's suggestion to create the endpoints in the code. When a new endpoint appears, you simply add another row to the table and force the service to re-query the endpoint table.

How to create a service endpoint in code http://msdn.microsoft.com/en-us/library/ms731080.aspx

0
source

All Articles