简体   繁体   English

将多个服务引用添加到一个C#项目

[英]Adding multiple service reference to one C# project

i have one c# project and database which is running on multiple branches separately, one of these branches is the main one and i call it the center , i want to send data from the center to other branches using web service , so there are equal web services running on each branch and i added all of them as service references to my center project manually , but when i want to add a new branch i have to add another service reference to my project manually again , is it possible to add different endpoint (branched ip addresses) dynamically to my project? 我有一个C#项目和数据库,它们分别在多个分支上运行,这些分支之一是主要分支,我称它为中心,我想使用Web服务从中心向其他分支发送数据,因此存在相等的Web在每个分支上运行的服务,我将所有这些作为服务引用手动添加到我的中心项目,但是当我想添加一个新分支时,我不得不再次手动向我的项目添加另一个服务引用,是否可以添加不同的终结点(分支IP地址)动态地添加到我的项目中? or all in all any other ideas to how i can manage sending and receiving data between center and branches? 或所有其他有关如何管理中心与分支之间的数据收发的想法? Thanks 谢谢

If you want to dynamically add endpoints, you can programmatically include connect. 如果要动态添加端点,则可以以编程方式包括connect。 You can read the connection data from your database and then add the endpoint with the ChannelFactory class. 您可以从数据库中读取连接数据,然后使用ChannelFactory类添加端点。 You can find an example here: 您可以在此处找到示例:

How to programmatically connect a client to a WCF service? 如何以编程方式将客户端连接到WCF服务?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM