开发者

Managing multiple WCF endpoints for the same service

I am building an single application that uses WCF to call out to multiple external endpoints. All of the remote endpoints are identical except for the URI. I would like to treat them as a pool: add and remove endpoints through configuration and have the application understand what to do.

My original plan was to define one endoint in the app.config, then iterate over my list of endpoints and update client.Endpoint.Address on the fly to point to the开发者_Python百科 right place. Unfortunately, that property is read-only, rendering that plan unworkable.

I'm a little bit stumped here. Any suggestions on how I might accomplish this?


How to: Create a Service Endpoint in Code shows you how to manage service endpoints in code rather than configuration.


Have you tried a separate name that is passed in to the client 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" />


Store the end point addresses in a DB table and use Jason's suggestion for creating end points in code. When a new endpoint shows up you just 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜